80
8 FAQ and Troubleshooting
Insomecases,mintedmaynotgivethedesiredresultduetootherdocumentsettings
thatitcannotcontrol. Commonissuesaredescribedbelow,withworkaroundsor
solutions. Youmayalsowishto searchtex.stackexchange.com oraskaquestion
there, ifyouareworkingwithmintedinanon-typicalcontext.
• I receive a “Too many open files” error under OS X when using
caching. Seethenote onOSX underSection4.1.
• When I use minted with KOMA-Script document classes, I get
warnings about
\float@addtolists
. mintedusesthefloatpackageto
producefloatedlistings,butthisconflictswiththe wayKOMA-Scriptdoes
floats. Load the package scrhack to resolve the conflict. Or use minted’s
newfloat
packageoption.
• Tildecharacters
~
are raised,almost likesuperscripts. . Thisisafont
issue. You need a different font encoding, possibly with a different font.
Try
\usepackage[T1]{fontenc}
, perhaps with
\usepackage{lmodern}
,
orsomethingsimilar.
• I’mgettingerrorswithmath,somethinglike
TeX capacity exceeded
and
\leavevmode\kern\z@
. Thisisduetoligaturesbeingdisabledwithin
verbatimcontent. See the noteunder
escapeinside
.
• Quotation marks and backticks don’t look right. Backtick char-
acters
‘
are appearing as left quotes. Single quotes are appear-
ing as curly right quotes. . This is due to how Pygments outputs
L
A
T
E
Xcode, combined with how L
A
T
E
X dealswith verbatim content. Try
\usepackage{upquote}
.
• I’m getting errors with Beamer. . DuetohowBeamertreatsverbatim
content,youmayneedtouseeitherthe
fragile
or
fragile=singleslide
options for frames that contain minted commands and environments.
fragile=singleslide
worksbest,butitdisablesoverlays.
fragile
works
bysavingthecontentsofeachframetoatempfileandthenreusingthem. This
approachallowsoverlays,butwillbreak if youhavethe string
\end{frame}
atthebeginningofaline(forexample,ina
minted
environment). Towork
around that, you can indentthe content ofthe environment (so thatthe
\end{frame}
isprecededbyone ormore spaces)andthenusethe
gobble
or
autogobble
optionstoremove the indentation.
• Tabs are eatenbyBeamer. . ThisisduetoabuginBeamer’streatment
ofverbatimcontent. UpgradeBeamerorusethelinkedpatch. Otherwise,
try
fragile=singleslide
if you don’t need overlays, or consider using
\inputminted
orconvertingthe tabsintospaces.
25
C# Imaging - C# Code 93 Generator Tutorial Users can freely adjust the coordinates to change barcode location on Create Code 93 on C# Document Page. Code 93 linear barcode pictures on PDF documents, multi
pdf encryption; secure pdf
50
• I’m trying to create several new minted commands/environments,
and want them all to have the same settings. I’m saving the set-
tings inamacro andthenusingthemacrowhendefining the com-
mands/environments. But it’s failing. . Thisisdue to theway that
keyval works (minted uses it to manage options). Arguments are not ex-
panded. Seethisandthisformoreinformation. Itisstillpossibletodowhat
you want; you justneed toexpand the optionsmacro before passingitto
the commandsthatcreate thenewcommands/environments. Anexampleis
shownbelow. The
\expandafter
isthevitalpart.
\def\args{linenos,frame=single,fontsize=\footnotesize,style=bw}
\newcommand{\makenewmintedfiles}[1]{%
\newmintedfile[inputlatex]{latex}{#1}%
\newmintedfile[inputc]{c}{#1}%
}
\expandafter\makenewmintedfiles\expandafter{\args}
• Iwant touse
\mintinline
inacontext that normallydoesn’t allow
verbatimcontent. The
\mintinline
commandwillalreadyworkinmany
placesthatdonotallow normalverbatimcommandslike
\verb
,so make
sure totryitfirst. Ifitdoesn’twork,one ofthesimplestalternativesisto
save yourcodeinabox,andthenuseitlater. Forexample,
\newsavebox\mybox
\begin{lrbox}{\mybox}
\mintinline{cpp}{std::cout}
\end{lrbox}
\commandthatdoesnotlikeverbatim{Text \usebox{\mybox}}
• Extended characters do not work inside minted commands and
environments,even when the inputenc package is used. . Version2.0
addssupportforextendedcharactersunderthepdfTeXengine. Butifyou
needcharactersthatarenotsupportedbyinputenc,youshouldusetheXeTeX
orLuaTeXenginesinstead.
• The polyglossia package is doing undesirable things to code. (For
example, adding extra space around colons in French.) ) Youmay
needto putyourcodewithin
\begin{english}...\end{english}
. This
may done forall
minted
environmentsusingetoolboxinthe preamble:
\usepackage{etoolbox}
\BeforeBeginEnvironment{minted}{\begin{english}}
\AfterEndEnvironment{minted}{\end{english}}
26
68
• Tabs are being turned into the character sequence
^^I
. This
happens when you use XeLaTeX. You need to use the
-8bit
command-line option so that tabs may be written correctly to tem-
porary files. See
http://tex.stackexchange.com/questions/58732/
how-to-output-a-tabulation-into-a-file
formoreonXeLaTeX’shan-
dlingoftabcharacters.
• The captionpackageproducesanerrorwhen
\captionof
andother
commands are used in combination with minted. . Loadthecaption
packagewiththeoption
compatibility=false
. Orbetteryet,useminted’s
newfloat
packageoption,whichprovidesbettercaptioncompatibility.
• Ineedalistingenvironmentthatsupports pagebreaks. . Thebuilt-in
listingenvironmentisastandardfloat;itdoesn’tsupportpagebreaks. You
willprobablywanttodefineanewenvironmentforlongfloats. Forexample,
\usepackage{caption}
\newenvironment{longlisting}{\captionsetup{type=listing}}{}
With the caption package, it is best to use minted’s
newfloat
package
option. See
http://tex.stackexchange.com/a/53540/10742
formoreon
listing
environmentswithpage breaks.
• I want to use a custom script/executable to access Pygments,
rather than
pygmentize
. Redefine
\MintedPygmentize
:
\renewcommand{\MintedPygmentize}{...}
• Iwanttousethecommand-lineoption
-output-directory
,orMiK-
TeX’s
-aux-directory
,but am gettingerrors. . Usethepackageoption
outputdir
tospecifythe locationofthe outputdirectory. Unfortunately,
thereisnoway forminted todetectthe outputdirectory automatically.
• I want extendedcharacters inframe labels,but am gettingerrors.
Thiscanhappenwithminted<2.0andPython2.7,duetoaterminalencoding
issuewithPygments.ItshouldworkwithanyversionofPythonwithminted
2.0+,whichprocesseslabelsinternally anddoesnotsendthemtoPython.
•
minted
environments have extra vertical space inside
tabular
. It
ispossibletocreateacustomenvironmentthateliminatesthe extraspace.
However, a general solution that behaves as expected in the presence of
adjacenttextremainstobe found.
Acknowledgements
KonradRudolph: SpecialthankstoPhilippStephaniandtherestof theguysfrom
comp.text.tex
and
tex.stackexchange.com
.
27
83
GeoffreyPoore: ThankstoMarcoDanielforthecodeon
tex.stackexchange.com
thatinspiredautomatic line breaking.
Version History
v2.1 (2015/09/09)
• Changingthehighlightingstylenownolongerinvolvesre-highlighing
code. Stylemaybechangedwithalmostnooverhead.
• Improvedcontrolofautomaticlinebreaks. Newoption
breakanywhere
allows line breaks anywhere when
breaklines=true
. The pre-
break and post-break symbols for these types of breaks may be
setwith
breakanywheresymbolpre
and
breakanywheresymbolpost
(#79). New option
breakafter
allows specifying characters after
which line breaks are allowed. Breaks between adjacent, identical
charactersmaybe controlledwith
breakaftergroup
. The pre-break
and post-break symbols for these types of breaks may be set with
breakaftersymbolpre
and
breakaftersymbolpost
.
•
breakbytoken
now only breaks lines between tokens that are sep-
arated by spaces, matching the documentation. The new option
breakbytokenanywhere
allowsfor breakingbetween tokensthatare
immediatelyadjacent. Fixedabugin
\mintinline
thatproducedafol-
lowinglinebreakwhen
\mintinline
wasthe firstthinginaparagraph
and
breakbytoken
wastrue(#77).
• Fixedabugindraftmodeoptionhandlingfor
\inputminted
(#75).
• Fixedabugwith
\MintedPygmentize
whenacustom
pygmentize
was
specifiedandthere wasno
pygmentize
onthedefaultpath(#62).
• AddednotetodocsoncachinglargenumbersofcodeblocksunderOSX
(#78).
• Added discussionof f currentlimitations s of
texcomments
(#66) and
escapeinside
(#70).
• PGF/TikZexternalization is automatically detectedand supported
(#73).
• ThepackageisnowcompatiblewithLAT
E
Xfileswhosenamescontain
spaces(#85).
v2.0 (2015/01/31)
• Addedthecompatibilitypackage
minted1
,whichprovidesthe minted
1.7code. Thismay beloadedwhen1.7compatibility isrequired. This
package workswithotherpackagesthat
\RequirePackage{minted}
,
solongasitisloadedfirst.
• Movedall old
\changes
into
changelog
.
28
133
Development releases for2.0 (2014–January 2015)
• Cachingisnowonbydefault.
• FixedabugthatpreventedcompilingunderWindowswhenfilenames
containedcommas.
• Added
breaksymbolleft
,
breaksymbolsepleft
,
breaksymbolindentleft
,
breaksymbolright
,
breaksymbolsepright
,and
breaksymbolindentright
options.
breaksymbol
,
breaksymbolsep
, and
breaksymbolindent
are nowaliasesforthe correspondent
*
left
options.
• Added
kpsewhich
package option. Thisuses
kpsewhich
tolocatethe
filesthatare tobehighlighted. Thisprovidescompatibilitywithbuild
toolslike
texi2pdf
thatfunctionby modifying
TEXINPUTS
(#25).
• Fixedabugthatprevented
\inputminted
fromworkingwith
outputdir
.
• Addedinformative errormessageswhenPygmentsoutputismissing.
• Added
final
packageoption(oppositeof
draft
).
• Renamedthedefaultcachedirectoryto
_minted-<jobname>
(replaced
leadingperiodwithunderscore). The leading periodcausedthecache
directory tobehiddenonmanysystems,whichwasapotentialsource
ofconfusion.
•
breaklines
and
breakbytoken
now workwith
\mintinline
(#31).
•
bgcolor
maynowbesetthrough
\setminted
and
\setmintedinline
.
• Whenmathisenabledvia
texcomments
,
mathescape
,or
escapeinside
,
spacecharactersnowbehaveasinnormalmathbyvanishing,insteadof
appearingasliteralspaces. Mathneednolongerbespeciallyformatted
toavoidundesiredspaces.
• Indefaultvalueof
\listoflistingscaption
,capitalized “Listings”
so thatcapitalizationisconsistentwithdefaultvaluesfor other lists
(figures,tables,algorithms,etc.).
• Added
newfloat
packageoptionthatcreatesthe
listing
environment
using
newfloat
ratherthan
float
,thusprovidingbettercompatibility
withthe
caption
package (#12).
• AddedsupportforPygmentsoption
stripall
.
• Added
breakbytoken
optionthatprevents
breaklines
frombreaking
lineswithinPygmentstokens.
•
\mintinline
uses a
\colorbox
when
bgcolor
is set, to give more
reasonablebehavior(#57).
• ForPHP,
\mintinline
automaticallybeginswith
startinline=true
(#23).
• Fixedabugthatthrewofflinenumberingin
minted
when
langlinenos=false
and
firstnumber=last
. Fixed abugin
\mintinline
thatthrew off
subsequentlinenumberingwhen
langlinenos=false
and
firstnumber=last
.
29
91
• Improvedbehaviorof
\mint
and
\mintinline
in
draft
mode.
• The
\mint
command nowhasthe additional capabilityto takecode
delimitedbypairedcurlybraces
{}
.
• Itisnowpossibletosetoptionsonlyfor
\mintinline
usingthe new
\setmintedinline
command. Inlineoptionsoverrideoptionsspecified
via
\setminted
.
• Completelyrewroteoptionhandling. fancyvrboptionsarenowhandled
ontheL
A
T
E
Xside directly,ratherthanbeing passedto Pygmentsand
thenreturned. Thismakescachingmoreefficient,sincecodeisnolonger
rehighlightedjustbecause fancyvrboptionschanged.
• Fixedbuffersizeerrorcausedbyusing
cache
withavery large number
offiles(#61).
• Fixed
autogobble
bugthatcausedfailure undersomeoperatingsys-
tems.
• Addedsupportfor
escapeinside
(requiresPygments2.0+;#38).
• FixedissueswithXeTeXandcaching(#40).
• The
upquote
package now works correctly with single quotes when
usingPygments1.6+(#34).
• FixedcachingincompatibilitywithLinuxandOSXunderxelatex(#18
and#42).
• Fixed
autogobble
incompatibility withLinux andOSX.
•
\mintinline
andderivedcommandsarenowrobust,via
\newrobustcmd
from
etoolbox
.
• Unusedstylesarenowcleanedupwhencaching.
• Fixedabugthatcouldinterfere withcaching(#24).
• Added
draft
package option (#39). This typesets all code using
fancyvrb
;Pygmentsisnotused. Thistradessyntaxhighlightingfor
maximumspeedincompiling.
• Addedautomaticlinebreakingwith
breaklines
andrelatedoptions
(#1).
• Fixeda bugwithboolean optionsthatneededaFalseargumentto
cooperatewith
\setminted
(#48).
v2.0-alpha3 (2013/12/21)
• Added
autogobble
option. This sends code through Python’s
textwrap.dedent()
toremovecommonleadingwhitespace.
• Addedpackageoption
cachedir
. Thisallows the directoryinwhich
cachedcontentissavedtobespecified.
• Addedpackage option
outputdir
. This allows an output directory
fortemporaryfilestobespecified,so thatthe packagecanworkwith
LaTeX’s
-output-directory
command-lineoption.
30
Documents you may be interested
Documents you may be interested