How to show Greek letters of Julia Code in Lyx

I use Lyx as my text editing tool, but found that all Greek letters disappeared after I inserted a block of Julia code in my lyx file.

I want to ask if anyone knows how to insert Julia code without losing Greek letters.

The best way I’ve found is to include the source file with Minted, with XeTeX as the processor. This lets you keep all the nice UTF8 goodness and gives you properly-highlighted output.

  1. Install Minted
  2. Within LyX/Preferences/File Handling/Converters, find LaTeX (XeTeX) -> PDF (XeTeX) and change the converter to xelatex -shell-escape $$i, with the extra flag latex=xelatex
  3. In the document preamble, \usepackage[cache=false]{minted}
  4. Within LyX/Document Settings/Fonts, change the typewriter font to whichever whatever system font your Julia editor uses.
  5. Wherever you want the Julia code to appear, include the source file with \inputminted[fontsize=\footnotesize,breaklines,linenos]{julia}{/full/path/to/file.jl}
  6. Use the secondary View button and select View PDF (XeTeX)
3 Likes

Thanks for your reply. I would like to know if it is possible to do it like this in Lyx:

Insert - Box - Programming Listing - Julia

I could not find Julia in the options, so I have to use Matlab since they have similar syntax. Is there any way I could download the Julia Programming Listing Package for Lyx?

If you want to use the Listings package, you’ll need to include the following in your document preamble:

\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\footnotesize,
    keywordstyle     = \bfseries\color{blue},
    stringstyle      = \color{magenta},
    commentstyle     = \color{ForestGreen},
    showstringspaces = false,
}
1 Like