Skip to content

Instantly share code, notes, and snippets.

@chi-feng
Created September 17, 2013 01:38
Show Gist options
  • Save chi-feng/6589066 to your computer and use it in GitHub Desktop.
Save chi-feng/6589066 to your computer and use it in GitHub Desktop.
Latex Listings language definition/style for Julia
\usepackage{inconsolata} % very nice fixed-width font included with texlive-full
\usepackage[usenames,dvipsnames]{color} % more flexible names for syntax highlighting colors
\usepackage{listings}
\lstset{
basicstyle=\ttfamily,
columns=fullflexible, % make sure to use fixed-width font, CM typewriter is NOT fixed width
numbers=left,
numberstyle=\small\ttfamily\color{Gray},
stepnumber=1,
numbersep=10pt,
numberfirstline=true,
numberblanklines=true,
tabsize=4,
lineskip=-1.5pt,
extendedchars=true,
breaklines=true,
keywordstyle=\color{Blue}\bfseries,
identifierstyle=, % using emph or index keywords
commentstyle=\sffamily\color{OliveGreen},
stringstyle=\color{Maroon},
showstringspaces=false,
showtabs=false,
upquote=false,
texcl=true % interpet comments as LaTeX
}
\lstdefinelanguage{julia}
{
keywordsprefix=\@,
morekeywords={
exit,whos,edit,load,is,isa,isequal,typeof,tuple,ntuple,uid,hash,finalizer,convert,promote,
subtype,typemin,typemax,realmin,realmax,sizeof,eps,promote_type,method_exists,applicable,
invoke,dlopen,dlsym,system,error,throw,assert,new,Inf,Nan,pi,im,begin,while,for,in,return,
break,continue,macro,quote,let,if,elseif,else,try,catch,end,bitstype,ccall,do,using,module,
import,export,importall,baremodule,immutable,local,global,const,Bool,Int,Int8,Int16,Int32,
Int64,Uint,Uint8,Uint16,Uint32,Uint64,Float32,Float64,Complex64,Complex128,Any,Nothing,None,
function,type,typealias,abstract
},
sensitive=true,
morecomment=[l]{\#},
morestring=[b]',
morestring=[b]"
}
@ATElve
Copy link

ATElve commented Nov 29, 2013

Thanks

@DaubyP
Copy link

DaubyP commented May 7, 2015

Thanks a lot ! I think you could add the line
" morecomment=[s]{# =}{=#}, "
in order to make delimited comments possible. I aslo had some issues with the "texcl=true" that are solved once I change to false. Once again, thanks !

@wg030
Copy link

wg030 commented Jan 26, 2018

For those of you who are intrested in a language definition that looks similiar to the one that is used in the official julia documentation check out my project jlcode: https://github.com/wg030/jlcode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment