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.
FreeMono
). Thelatexmk
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?.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.