4

I've asked the Julia community here my question, and have gotten some nice help.

I thought I might cast a wider net for clarification.

TL; DR: What is the complete setup for VSCode to run XeLaTeX or LuaLaTeX, with working examples using unicode characters with minted? I've looked everywhere, finding the latex-workshop.latex.tools in one spot, the latex-workshop.latex.recipes in another spot, then example .tex files elsewhere, and they don't play nicely together. I am so confused.

So, I am new to the world of programming and spend more than half my time lost trying to understand what on earth everyone is talking about.

In this answer to a Stack Exchange question, Brad gives an example without the need to "define" new unicode characters (as with another answer to that question) because it has a huge variety of them.

In this post, the creator of LaTeX-Workshop discourages the use of the magic comment which is used in the Stack Exchange answer aforementioned, so I've deleted it. I also have no idea where the latex-workshop.latex.toolchain is meant to be copied-and-pasted (or edited).

I've learned from here that minted is better than listings because the former takes in the syntax highlighting and formatting rules from pygmentize, which I have installed through the python installer.

I've obtained an example of defining the xelatex tool from here. But it has no example of a recipe.

This guy's example isn't specific enough for me, i.e. VSCode settings are unclear to me.

The guy who replied to me in the Julia discourse community showed that the compilation works in Overleaf. I took his suggestion and tried compiling via the command line, but it doesn't work either.

The JuliaProgramming.tex file I have is as follows,

\documentclass[12pt]{article}

\usepackage[letterpaper]{geometry}
\usepackage{fontspec,unicode-math}
\usepackage{xunicode}
\usepackage{minted}

\setmonofont{FreeMono}

\begin{document}

\section{Example Code}
Hello, here is some code.

\begin{minted}{julia}
f(x) = x.^2 + π
const ⊗ = kron
const Σ = sum # Although `sum` may be just as good in the code.
# Calculate Σ_{j=1}^5 j^2
Σ([j^2 for j ∈ 1:5])
\end{minted}

\end{document}

With the following as my settings.json file for VSCode.

{
    "latex-workshop.latex.recipes": [
        {
            "name": "latexmk",
            "tools": "latexmk"
        }
    ],
    "latex-workshop.latex.tools": [
        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "--shell-escape",
                "-xelatex",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ]
        }
    ]
}

Are these sufficient for a successful run? It doesn't run successfully for me.

Edit: The output I get from running my .tex file is very lengthy. Some of the lines are/include (and repeat many times):

Sorry, but miktex-makemf did not succeed.

! Package fontspec Error: The font "FreeMono" cannot be found.

`BI' can't be a subfont created by hbf2gf

The log file hopefully contains the information to get MiKTeX going again:

C:\<Path>\Local\MiKTeX\2.9\miktex\log\miktex-maketfm.log

I could check the log file. I could try to install the font FreeMono. But I’ve been exploring rabbit holes for too long and I’m tired of it now.

4
  • 3
    The example works fine for me once I install the required font (FreeMono). The latexmk settings look sensible, but I have never used VSCode, so I can't tell you if they'll really do what they are supposed to. If things go wrong there should be a .log file that tells you about the errors, what does it say? Can you include the relevant bits in the question and upload the whole .log to a text-sharing website such as pastebin.com, please?
    – moewe
    Commented Jul 20, 2019 at 5:36
  • 1
    What has happened for you compiling on the command line? Which errors have been thrown? The example given should work there…
    – TeXnician
    Commented Jul 20, 2019 at 21:55
  • I get a lot of output. And I mean a lot. I'll edit my question to add some of the lines of output that seem most significant.
    – kapple
    Commented Jul 22, 2019 at 7:09
  • 1
    The shown bit of the .log file unfortunately only lets on that XeLaTeX doesn't find FreeMono. Have you made sure that the font is installed on your machine? Apparently it is sometimes safer to load a font by file name (\setmonofont{FreeMono.otf}) rather than by font name.
    – moewe
    Commented Jul 23, 2019 at 5:34

1 Answer 1

1
  1. Be sure you have FreeMono installed on you machine. On GNU/Linux, you can check it by typing fc-list
  2. Include \usepackage{polyglossia} on your preamble, click here for more info.
  3. Be sure you are using LuaLaTeX or XeLaTeX
\documentclass{article}
\usepackage{minted}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{unicode-math}

\usepackage{xunicode}
\setmonofont{FreeMono} %switched to FreeMono

\begin{document}

\section{Example Code}
Hello, here is some code.

\begin{minted}{julia}
f(x) = x.^2 + π
const ⊗ = kron
const Σ = sum # Although `sum` may be just as good in the code.
# Calculate Σ_{j=1}^5 j^2
Σ([j^2 for j ∈ 1:5])
\end{minted}

\end{document}

enter image description here

1
  • @ I think long term is better to run through LuaTeX, you can skip the xunicode package. Also you do not need the polyglossia package. Did I miss something?
    – yannisl
    Commented Jan 12 at 5:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .