welcome: please sign in
location: Diff for "Computer/Latex/Juliacode"
Differences between revisions 1 and 13 (spanning 12 versions)
Revision 1 as of 2016-03-30 12:06:22
Size: 1325
Editor: fredrikb
Comment:
Revision 13 as of 2018-12-12 15:46:40
Size: 2300
Editor: fredrikb
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## page was renamed from juliacode
#acl Known:read,write,admin,delete,revert All:read

Line 6: Line 10:
sudo pip install pygmentize pygmentize is required, if it is not installed, try running
''sudo pip install pygments''
Line 8: Line 13:
Get latest version of minted.sty from the github repo above. Put it in you texlive package folder or in the current working directory. Get latest version of ''minted.sty'' from the github repo above. Put it in you texlive package folder or in the current working directory.
Line 12: Line 17:
  \begin{minted}[escapeinside=||,mathescape=true, linenos, numbersep=3pt, gobble=2, frame=lines, fontsize=\small, framesep=2mm]{julia}   \begin{minted}[breaklines,escapeinside=||,mathescape=true, linenos, numbersep=3pt, gobble=2, frame=lines, fontsize=\small, framesep=2mm]{julia}
Line 16: Line 21:
[[minted.tex|example]] [[https://www.control.lth.se/media/Staff/FredrikBaggeCarlson/minted.tex|minted.tex]]
[[https://www.control.lth.se/media/Staff/FredrikBaggeCarlson/minted.pdf|minted.pdf]]
Line 25: Line 31:

With luatex, use the following instead
\usepackage[T1]{fontenc}
\usepackage{unicode-math}

See https://tex.stackexchange.com/questions/251446/problem-with-math-symbols-unicode-math for info regarding setting a math font. The following selects the font that is default in Atom

\usepackage{fontspec}\setmonofont{DejaVu Sans Mono}[Scale=0.8]

Note, there might be some conflicts between unicode-math and the department fonts. If you get errors, try removing all other font choices, such as schoolbook, newtxtext, newtxmath,inconsolata,fourier, and see if the erros go away.
Line 36: Line 52:
Minted has issues if the build output is stored in a subdirectory and not in the working directory. Some workaround to this is floating around on the interwebs. Minted has issues if the build output is stored in a subdirectory and not in the working directory, use
\usepackage[outputdir=build]{minted}

If ''pygments'' is installed but ''pygmentize'' can not be found, reinstall ''pygments''
.

Minted

It is possible to include julia code using the package minted https://github.com/gpoore/minted

Prerequisites

pygmentize is required, if it is not installed, try running sudo pip install pygments

Get latest version of minted.sty from the github repo above. Put it in you texlive package folder or in the current working directory. Minted has other prerequisites, but those should be installed already.

A small example

  • \begin{minted}[breaklines,escapeinside=||,mathescape=true, linenos, numbersep=3pt, gobble=2, frame=lines, fontsize=\small, framesep=2mm]{julia}

    • Your awesome julia code here
    \end{minted}

minted.tex minted.pdf

Inclusion of unicode characters

With julia, one has the option of including most unicode characters in the code. For a copy-paste-kind of strategy to work, I have found the following two packages useful

\usepackage[mathletters]{ucs} \usepackage[utf8x]{inputenc}

With these packages, unicode characters in the input are handled quite well. At least if one builds with latexmk and pdflatex.

With luatex, use the following instead \usepackage[T1]{fontenc} \usepackage{unicode-math}

See https://tex.stackexchange.com/questions/251446/problem-with-math-symbols-unicode-math for info regarding setting a math font. The following selects the font that is default in Atom

\usepackage{fontspec}\setmonofont{DejaVu Sans Mono}[Scale=0.8]

Note, there might be some conflicts between unicode-math and the department fonts. If you get errors, try removing all other font choices, such as schoolbook, newtxtext, newtxmath,inconsolata,fourier, and see if the erros go away.

Issues

Beamer

Frames must be declared fragile for minted to work

\begin{frame}[fragile]

Other issues

Minted has issues if the build output is stored in a subdirectory and not in the working directory, use \usepackage[outputdir=build]{minted}

If pygments is installed but pygmentize can not be found, reinstall pygments.

Computer/Latex/Juliacode (last edited 2018-12-12 15:46:40 by fredrikb)