The culprit is stringstyle=\color{white}\ttfamily
. After all, seeing white text on a white background is rather hard :).
Simply removing \color{white}
or replacing it by some other color (e.g., \color{blue}
) will solve the problem.
You'll find a listings
language definition for the Julia language in the code below.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{beramono}
\usepackage{listings}
\usepackage[usenames,dvipsnames]{xcolor}
%%
%% Julia definition (c) 2014 Jubobs
%%
\lstdefinelanguage{Julia}%
{morekeywords={abstract,break,case,catch,const,continue,do,else,elseif,%
end,export,false,for,function,immutable,import,importall,if,in,%
macro,module,otherwise,quote,return,switch,true,try,type,typealias,%
using,while},%
sensitive=true,%
alsoother={$},%
morecomment=[l]\#,%
morecomment=[n]{\#=}{=\#},%
morestring=[s]{"}{"},%
morestring=[m]{'}{'},%
}[keywords,comments,strings]%
\lstset{%
language = Julia,
basicstyle = \ttfamily,
keywordstyle = \bfseries\color{blue},
stringstyle = \color{magenta},
commentstyle = \color{ForestGreen},
showstringspaces = false,
}
\begin{document}
\begin{lstlisting}
#= This is a code sample for the Julia language
(adapted from http://julialang.org) =#
function mandel(z)
c = z
maxiter = 80
for n = 1:maxiter
if abs(z) > 2
return n-1
end
z = z^2 + c
end
return maxiter
end
function helloworld()
println("Hello, World!") # Bye bye, MATLAB!
end
function randmatstat(t)
n = 5
v = zeros(t)
w = zeros(t)
for i = 1:t
a = randn(n,n)
b = randn(n,n)
c = randn(n,n)
d = randn(n,n)
P = [a b c d]
Q = [a b; c d]
v[i] = trace((P.'*P)^4)
w[i] = trace((Q.'*Q)^4)
end
std(v)/mean(v), std(w)/mean(w)
end
\end{lstlisting}
\end{document}
Best Answer
Use the
minted
package. It does syntax highlighting with thepygments
Python library, which happens to support Julia.Additionally, Julia interactive output is supported through the
jlcon
lexer. It's not listed on the main site's language list, but it is listed onpygmentize -L
.