gpoore / minted

minted is a LaTeX package that provides syntax highlighting using the Pygments library. Highlighted source code can be customized using fancyvrb.
1.73k stars 125 forks source link

autogobble option not working for me #391

Open kjshen opened 3 months ago

kjshen commented 3 months ago

The following minimal working example

\documentclass{article}
\usepackage{minted}
\setminted{autogobble}
\begin{document}
\begin{minted}[autogobble]{c}
    printf("hello, world");
\end{minted}
\begin{minted}[gobble=4]{c}
    printf("hello, world");
\end{minted}
\begin{minted}{c}
printf("hello, world");
\end{minted}
\end{document}

results in: grafik

The first listing should not be indented, but give the same result as the other two.

Does anyone else have this behavior?

gpoore commented 3 months ago

Everything is working as expected for me.

Are you using tabs or spaces for indentation? What command are you using to compile?

kjshen commented 3 months ago

Thanks for checking, good to know. I'm using pdfTeX with pdflatex -shell-escape -synctex=1 -interaction=nonstopmode %DOC% this is my log file:

This is pdfTeX, Version 3.141592653-2.6-1.40.26 (MiKTeX 24.3) (preloaded format=pdflatex 2024.3.30)  30 MAR 2024 22:06
entering extended mode
 \write18 enabled.
 %&-line parsing enabled.
**c:/Sciebo/LaTeX/01_minimal_working_examples/mwe_minted.tex
(c:/Sciebo/LaTeX/01_minimal_working_examples/mwe_minted.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-03-14>
(C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/base\article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/base\size10.clo
File: size10.clo 2023/05/17 v1.4n Standard LaTeX file (size option)
)
\c@part=\count188
\c@section=\count189
\c@subsection=\count190
\c@subsubsection=\count191
\c@paragraph=\count192
\c@subparagraph=\count193
\c@figure=\count194
\c@table=\count195
\abovecaptionskip=\skip48
\belowcaptionskip=\skip49
\bibindent=\dimen140
) (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/minted\minted.sty
Package: minted 2023/12/18 v2.9 Yet another Pygments shim for LaTeX
 (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/graphics\keyval.sty
Package: keyval 2022/05/29 v1.15 key=value parser (DPC)
\KV@toks@=\toks17
) (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/kvoptions\kvoptions.sty
Package: kvoptions 2022-06-15 v3.15 Key value format for package options (HO)
 (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/generic/ltxcmds\ltxcmds.sty
Package: ltxcmds 2023-12-04 v1.26 LaTeX kernel commands for general use (HO)
) (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/kvsetkeys\kvsetkeys.sty
Package: kvsetkeys 2022-10-05 v1.19 Key value parser (HO)
)) (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/fvextra\fvextra.sty
Package: fvextra 2023/11/28 v1.6.1 fvextra - extensions and patches for fancyvrb
 (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/etoolbox\etoolbox.sty
Package: etoolbox 2020/10/05 v2.5k e-TeX tools for LaTeX (JAW)
\etb@tempcnta=\count196
) (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/fancyvrb\fancyvrb.sty
Package: fancyvrb 2024/01/20 4.5c verbatim text (tvz,hv)
\FV@CodeLineNo=\count197
\FV@InFile=\read2
\FV@TabBox=\box51
\c@FancyVerbLine=\count198
\FV@StepNumber=\count199
\FV@OutFile=\write3
) (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/upquote\upquote.sty
Package: upquote 2012/04/19 v1.3 upright-quote and grave-accent glyphs in verbatim
) (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/lineno\lineno.sty
Package: lineno 2023/05/20 line numbers on paragraphs v5.3
\linenopenalty=\count266
\output=\toks18
\linenoprevgraf=\count267
\linenumbersep=\dimen141
\linenumberwidth=\dimen142
\c@linenumber=\count268
\c@pagewiselinenumber=\count269
\c@LN@truepage=\count270
\c@internallinenumber=\count271
\c@internallinenumbers=\count272
\quotelinenumbersep=\dimen143
\bframerule=\dimen144
\bframesep=\dimen145
\bframebox=\box52
LaTeX Info: Redefining \\ on input line 3180.
)
\c@FancyVerbWriteLine=\count273
\c@FancyVerbBufferIndex=\count274
\c@FancyVerbBufferLength=\count275
\c@FancyVerbBufferLine=\count276
\c@FV@oldbufferlength=\count277
\c@FV@TrueTabGroupLevel=\count278
\c@FV@TrueTabCounter=\count279
\FV@TabBox@Group=\box53
\FV@TmpLength=\skip50
\c@FV@HighlightLinesStart=\count280
\c@FV@HighlightLinesStop=\count281
\FV@LoopCount=\count282
\FV@NCharsBox=\box54
\FV@BreakIndent=\dimen146
\FV@BreakIndentNChars=\count283
\FV@BreakSymbolSepLeft=\dimen147
\FV@BreakSymbolSepLeftNChars=\count284
\FV@BreakSymbolSepRight=\dimen148
\FV@BreakSymbolSepRightNChars=\count285
\FV@BreakSymbolIndentLeft=\dimen149
\FV@BreakSymbolIndentLeftNChars=\count286
\FV@BreakSymbolIndentRight=\dimen150
\FV@BreakSymbolIndentRightNChars=\count287
\c@FancyVerbLineBreakLast=\count288
\FV@LineBox=\box55
\FV@LineIndentBox=\box56
\c@FV@BreakBufferDepth=\count289
\FV@LineWidth=\dimen151
) (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/base\ifthen.sty
Package: ifthen 2022/04/13 v1.1d Standard LaTeX ifthen package (DPC)
) (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/tools\shellesc.sty
Package: shellesc 2023/07/08 v1.0d unified shell escape interface for LaTeX
Package shellesc Info: Unrestricted shell escape enabled on input line 75.
) (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/ifplatform\ifplatform.sty
Package: ifplatform 2017/10/13 v0.4a Testing for the operating system
 (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/generic/pdftexcmds\pdftexcmds.sty
Package: pdftexcmds 2020-06-27 v0.33 Utility functions of pdfTeX for LuaTeX (HO)
 (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/generic/infwarerr\infwarerr.sty
Package: infwarerr 2019/12/03 v1.5 Providing info/warning/error messages (HO)
) (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/generic/iftex\iftex.sty
Package: iftex 2022/02/03 v1.0f TeX engine tests
)
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode found.
) (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/generic/catchfile\catchfile.sty
Package: catchfile 2019/12/09 v1.8 Catch the contents of a file (HO)
 (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/generic/etexcmds\etexcmds.sty
Package: etexcmds 2019/12/15 v1.7 Avoid name clashes with e-TeX commands (HO)
)) (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/generic/iftex\ifluatex.sty
Package: ifluatex 2019/10/25 v1.5 ifluatex legacy package. Use iftex instead.
)) (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/xstring\xstring.sty (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/generic/xstring\xstring.tex
\xs_counta=\count290
\xs_countb=\count291
)
Package: xstring 2023/08/22 v1.86 String manipulations (CT)
) (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/framed\framed.sty
Package: framed 2011/10/22 v 0.96: framed or shaded text with page breaks
\OuterFrameSep=\skip51
\fb@frw=\dimen152
\fb@frh=\dimen153
\FrameRule=\dimen154
\FrameSep=\dimen155
) (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/float\float.sty
Package: float 2001/11/08 v1.3d Float enhancements (AL)
\c@float@type=\count292
\float@exts=\toks19
\float@box=\box57
\@float@everytoks=\toks20
\@floatcapt=\box58
)
\minted@appexistsfile=\read3
\minted@bgbox=\box59
\minted@code=\write4
\c@minted@FancyVerbLineTemp=\count293
\c@minted@pygmentizecounter=\count294
\@float@every@listing=\toks21
\c@listing=\count295
)
runsystem(if not exist _minted-mwe_minted mkdir _minted-mwe_minted)...executed.

 (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/xcolor\xcolor.sty
Package: xcolor 2023/11/15 v3.01 LaTeX color extensions (UK)
 (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/graphics-cfg\color.cfg
File: color.cfg 2016/01/02 v1.6 sample color configuration
)
Package xcolor Info: Driver file: pdftex.def on input line 274.
 (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/graphics-def\pdftex.def
File: pdftex.def 2022/09/22 v1.2b Graphics/color driver for pdftex
) (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/graphics\mathcolor.ltx)
Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1350.
Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1354.
Package xcolor Info: Model `RGB' extended on input line 1366.
Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1368.
Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1369.
Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1370.
Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1371.
Package xcolor Info: Model `Gray' substituted by `gray' on input line 1372.
Package xcolor Info: Model `wave' substituted by `hsb' on input line 1373.
)
runsystem(for ^%i in (pygmentize.exe pygmentize.bat pygmentize.cmd) do set > mwe_minted.aex <nul: /p x=^%~$PATH:i>> mwe_minted.aex)...executed.

runsystem(del mwe_minted.aex)...executed.

 (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/latex/l3backend\l3backend-pdftex.def
File: l3backend-pdftex.def 2024-03-14 L3 backend support: PDF output (pdfTeX)
\l__color_backend_stack_int=\count296
\l__pdf_internal_box=\box60
) (mwe_minted.aux)
\openout1 = `mwe_minted.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for TS1/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
 (C:\Users\MyUsername\AppData\Local\Programs\MiKTeX\tex/context/base/mkii\supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count297
\scratchdimen=\dimen156
\scratchbox=\box61
\nofMPsegments=\count298
\nofMParguments=\count299
\everyMPshowfont=\toks22
\MPscratchCnt=\count300
\MPscratchDim=\dimen157
\MPnumerator=\count301
\makeMPintoPDFobject=\count302
\everyMPtoPDFconversion=\toks23
)
\openout3 = `mwe_minted.pyg'.

 (_minted-mwe_minted/default.pygstyle) (_minted-mwe_minted/B1952A8286796C9DBC13EF942F097CA32798C30930F4F7773E02E7900DA410BB.pygtex)
\openout3 = `mwe_minted.pyg'.

 (_minted-mwe_minted/B1952A8286796C9DBC13EF942F097CA3122DE0BA9BDAD93544752B1532E918EE.pygtex)
\openout3 = `mwe_minted.pyg'.

 (_minted-mwe_minted/847033EA89D5D93055CF40D9AB1E156ADA8BA688012B0B0310F1D3C6B438BEEF.pygtex) [1

{C:/Users/MyUsername/AppData/Local/MiKTeX/fonts/map/pdftex/pdftex.map}] (mwe_minted.aux)
 ***********
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-03-14>
 ***********
runsystem(del mwe_minted.pyg)...executed.

 ) 
Here is how much of TeX's memory you used:
 5350 strings out of 474423
 106071 string characters out of 5742662
 1926496 words of memory out of 5000000
 27652 multiletter control sequences out of 15000+600000
 558237 words of font info for 37 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 77i,5n,79p,316b,442s stack positions out of 10000i,1000n,20000p,200000b,200000s
<C:/Users/MyUsername/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmr10.pfb><C:/Users/MyUsername/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmtt10.pfb>
Output written on mwe_minted.pdf (1 page, 21828 bytes).
PDF statistics:
 16 PDF objects out of 1000 (max. 8388607)
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)
gpoore commented 3 months ago

The log looks normal, with up-to-date packages. Is Pygments updated? Is the indentation spaces or tabs? Have you tried deleting the cache?

kjshen commented 2 months ago

Thanks for your suggestions! I have the latest Pygments version 2.17.2 installed. My indentation is all spaces.

I tried pip cache purge, but the result is still the same.

kjshen commented 2 months ago

Downgrading to Pygments 2.15 (my random pick) also didn't resolve the issue.

gpoore commented 2 months ago

Again, is the indentation spaces or tabs? Have you tried deleting the minted cache (_minted... directory/folder)?

kjshen commented 2 months ago

Hey, thanks for giving more feedback!

1) Its all spaces. 2) Ah, this is what cache meant. I just deleted it, but it did not resolve the issue.

muzimuzhi commented 2 months ago

@kjshen Can you attach a zip which contains your example tex file and all the aux and cache files created while compiling it?

kjshen commented 2 months ago

Hi, here's a zip file containing my compilation files including .aux and .log and the minted cache files.

mwe_minted.zip

muzimuzhi commented 2 months ago

The aux and cache files all look alright.

Do you have executable python?

Prepare a mwe_minted.pyg2 which contains an indented line like printf("hello, world");, what's the content of that file after executing

python -c "import sys; import os; import textwrap; from io import open; fname = os.path.expanduser(os.path.expandvars(\"mwe_minted.pyg2\")); f = open(fname, \"r\", encoding=\"UTF8\") if os.path.isfile(fname) else None; t = f.readlines() if f is not None else None; t_opt = t if t is not None else []; f.close() if f is not None else None; tmpfname = os.path.expanduser(os.path.expandvars(\"mwe_minted.pyg2\")); f = open(tmpfname, \"w\", encoding=\"UTF8\") if t is not None else None; fvstartnum = 0; fvstopnum = -1; s = max(0, fvstartnum-1); e = max(s, fvstopnum) if fvstopnum > 0 else len(t_opt); [f.write(textwrap.dedent(\"\".join(x))) for x in (t_opt[0:s], t_opt[s:e], t_opt[e:]) if x and t is not None]; f.close() if t is not None else os.remove(tmpfname);"
AntonC9018 commented 1 month ago

I had this issue the last time I used latex, #326 and it's been fixed. I'm experiencing this same issue again now.

AntonC9018 commented 1 month ago

Works fine on version 2.7 of minted