Zulip Chat Archive

Stream: general

Topic: including listings in LaTeX


Kenny Lau (Jun 05 2021 at 10:04):

@people who have successfully included LaTeX code (with unicode) in your LaTeX files, how did you do it?

Kenny Lau (Jun 05 2021 at 10:04):

I'm currently 37 layers deep in errors

Kenny Lau (Jun 05 2021 at 10:10):

Edit: it seems like all problems have been solved upon switching from pdflatex to lualatex

Eric Wieser (Jun 05 2021 at 10:21):

Unfortunately some paper submission systems only accept pdflatex

Eric Rodriguez (Jun 05 2021 at 10:22):

lualatex & minted, with this line:

Eric Rodriguez (Jun 05 2021 at 10:22):

\AtBeginEnvironment{minted}{%
  \renewcommand{\fcolorbox}[4][]{#4}}

Eric Wieser (Jun 05 2021 at 10:24):

If you update pygments you shouldn't need that line

Kenny Lau (Jun 05 2021 at 10:27):

edit: I don't know why, but suddenly minted is complaining that I do not have -shell-escape flag

Kenny Lau (Jun 05 2021 at 10:28):

but earlier it didn't

Kenny Lau (Jun 05 2021 at 10:28):

because I typed the flag into the VSCode extension settings

Eric Rodriguez (Jun 05 2021 at 10:30):

Eric Wieser said:

If you update pygments you shouldn't need that line

ooh that's nice, thanks for fixing that

Kenny Lau (Jun 05 2021 at 10:31):

    "latex-workshop.latex.tools": [
        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                //"-xelatex",
                "-lualatex",
                "-shell-escape",              // <---- added this line
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-shell-escape",              // <---- added this line
                "-lualatex",
                "-shell-escape",              // <---- added this line
                "-outdir=%OUTDIR%",
                "%DOC%"
            ],
            "env": {}
        }
    ]

Kenny Lau (Jun 05 2021 at 10:31):

I told it three times already

Kenny Lau (Jun 05 2021 at 10:31):

surely it should enable -shell-escape right

Eric Rodriguez (Jun 05 2021 at 10:32):

        {
            "name": "shellualatexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-shell-escape",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ],
            "env": {}
        },

works for me

Eric Rodriguez (Jun 05 2021 at 10:32):

try maybe remove the -xelatex line instead of commenting it out?

Kenny Lau (Jun 05 2021 at 10:33):

but where do you specify to use lualatex

Eric Wieser (Jun 05 2021 at 10:33):

There's another pygments bug that I have a PR out for here: https://github.com/pygments/pygments/pull/1817

Eric Rodriguez (Jun 05 2021 at 10:34):

that's... actually a good question

Eric Rodriguez (Jun 05 2021 at 10:34):

i think latexmk is lualatex by default maybe?

Eric Wieser (Jun 05 2021 at 10:34):

Bryan is the one to thank for fixing the red boxes I think

Eric Rodriguez (Jun 05 2021 at 10:40):

yeah, I just checked and it definitely runs LuaHBTeX, even though I didn't tell it to

Eric Rodriguez (Jun 05 2021 at 10:40):

that's interesting

Kenny Lau (Jun 05 2021 at 10:49):

ok I think my -shell-escape error is caused by me using magic command to override

Kenny Lau (Jun 05 2021 at 10:49):

% !TEX program = lualatex -shell-escape

Eric Rodriguez (Jun 05 2021 at 10:50):

ahh, and the reason i get luatex by default is because i have a latexmk config file:

Eric Rodriguez (Jun 05 2021 at 10:50):

$pdflatex = 'lualatex %O %S';
$pdf_mode = 1;
$postscript_mode = $dvi_mode = 0;
$MSWin_back_slash = 0;

Kenny Lau (Jun 05 2021 at 10:54):

![](https://starecat.com/content/wp-content/uploads/my-code-doesnt-work-i-have-no-idea-why-my-code-works.jpg)

Kenny Lau (Jun 05 2021 at 10:59):

30b1gx.jpg

Kenny Lau (Jun 05 2021 at 11:04):

ok so I switched to lualatex and then somehow \C is used to I can't use it to mean C\Bbb C so I had to change that command

Kenny Lau (Jun 05 2021 at 11:04):

but then it's fine

Kenny Lau (Jun 05 2021 at 11:05):

never mind, it isn't fine, the symbols are missing

Eric Rodriguez (Jun 05 2021 at 11:05):

the symbols? lualatex supports unicode

Kenny Lau (Jun 05 2021 at 11:06):

I've been told that

Eric Wieser (Jun 05 2021 at 11:11):

It could be a font issue now

Kenny Lau (Jun 05 2021 at 11:12):

what is luahbtex?

Eric Rodriguez (Jun 05 2021 at 11:17):

got a different font renderer

Eric Rodriguez (Jun 05 2021 at 11:17):

basically allows colourful emoji

Kenny Lau (Jun 05 2021 at 11:17):

I swear it worked at one point

Kenny Lau (Jun 05 2021 at 11:17):

but I have no idea what the settings were

Kenny Lau (Jun 05 2021 at 11:17):

which is very frustrating

Kenny Lau (Jun 05 2021 at 11:19):

[73
Missing character: There is no  (U+2081) in font [lmmono10-regular]:!
Missing character: There is no  (U+2115) in font [lmmono10-regular]:!
Missing character: There is no  (U+2115) in font [lmmono10-regular]:!
Missing character: There is no λ (U+03BB) in font [lmmono10-regular]:!
Missing character: There is no λ (U+03BB) in font [lmmono10-regular]:!
]

Kenny Lau (Jun 05 2021 at 11:19):

wow i found these in over 2000 lines of log

Patrick Massot (Jun 05 2021 at 11:38):

Kenny, are you using VScode to type LaTeX?! With Lean we are somewhat forced to use VSCode but for LaTeX you should definitely use some decent editor such as emacs or vim.

Kenny Lau (Jun 05 2021 at 11:46):

those are so difficult to learn

Mario Carneiro (Jun 05 2021 at 15:14):

I haven't had a major problem using vscode + latex workshop to write latex, although I haven't done anything using lualatex or shell aliases

Kenny Lau (Jun 05 2021 at 17:38):

@Chris Hughes pointed me to this file which contains a lot of unicode replacements: https://github.com/leanprover-community/lean/blob/master/extras/latex/lstlean.tex

Eric Wieser (Jun 22 2021 at 08:39):

Has anyone had any luck making lean listings copy-pastable from pdflatex PDFs?

Eric Wieser (Jun 22 2021 at 10:46):

I was able to get this working with the accsupppackage in adobe (but not sumatra which has no support for ActualText) using lines like:

\newunicodechar{}{\BeginAccSupp{method=hex,unicode,ActualText=2115}\ensuremath{\mathbb{N}}\EndAccSupp{}}

where 2115 is the utf-16-be encoding of .


Last updated: Dec 20 2023 at 11:08 UTC