delph-in / docs

DELPH-IN Documentation

Home Page:https://delph-in.github.io/docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TDL in LaTeX

arademaker opened this issue · comments

Do we have any package or extension for https://www.overleaf.com/learn/latex/Code_listing to show TDL code?

In my dissertation I just did some ad-hoc listings style for transfer rules only (see below). Perhaps you could extend it?

Another alternative is to use the minted package with a Pygments style. I have a complete Pygments lexer for TDL in the delphin.highlight package. See this article for instructions (I haven't tested them) for using custom lexers with Minted in Overleaf.

Listings style for transfer rules:

\lstdefinestyle{MtrStyle}{
  basicstyle=\ttfamily\footnotesize,
  alsoletter={-+*\#},
  morekeywords=[2]{
    CONTEXT,INPUT,FILTER,OUTPUT,FLAGS,OPTIONAL,
    LTOP,INDEX,RELS,HCONS,
    PRED,LBL,ARG0,ARG1,ARG2,ARG3,ARG4,
    L-INDEX,L-HNDL,R-INDEX,R-HNDL,RSTR,CARG,
    qeq,HARG,LARG
  },
  morekeywords=[3]{
    \#x0, \#x1, \#x2, \#x3, \#x4, \#x5, \#x6, \#x7, \#x8, \#x9, \#x,
    \#e0, \#e1, \#e2, \#e3, \#e4, \#e5, \#e6, \#e7, \#e8, \#e9, \#e,
    \#h0, \#h1, \#h2, \#h3, \#h4, \#h5, \#h6, \#h7, \#h8, \#h9, \#h,
    \#i0, \#i1, \#i2, \#i3, \#i4, \#i5, \#i6, \#i7, \#i8, \#i9, \#i,
    \#p0, \#p1, \#p2, \#p3, \#p4, \#p5, \#p6, \#p7, \#p8, \#p9, \#p,
    \#u0, \#u1, \#u2, \#u3, \#u4, \#u5, \#u6, \#u7, \#u8, \#u9, \#u
  },
  keywordstyle=[2]{\color{uwpurplergb!70}},  % red!50!blue
  keywordstyle=[3]{\bfseries\color{uwmetalicgoldrgb}},  % orange
  stringstyle={\itshape\color{uwgoldrgb!50!uwmetalicgoldrgb}},  % green!70!black
  %mathescape=true,
  linewidth=0.9\linewidth
}

(aside: yes, I used official UW brand colors for the syntax highlighting (and throughout my dissertation) and, no, I don't think anyone ever appreciated that fact...)

How can I define does colors?

Here are my definitions:

% see: http://www.washington.edu/brand/graphic-elements/primary-color-palette/                            
                                                                                                          
\definecolor{uwpurple}{rgb}{.29,.18,.51}         % HEX 4b2e83 = (75,46,131)                               
\definecolor{uwpurplergb}{rgb}{.20,.00,.44}      % RGB 255    = (51,0,111)                                
\definecolor{uwgold}{rgb}{.72,.65,.48}           % HEX b7a57a = (183,165,122)                             
\definecolor{uwgoldrgb}{rgb}{.91,.83,.64}        % RGB 255    = (232,211,162)                             
\definecolor{uwgoldweb}{rgb}{.91,.89,.83}        % HEX e8e3d3 = (232,227,211)                             
\definecolor{uwmetalicgold}{rgb}{.52,.46,.30}    % HEX 85754d = (133,117,77)                              
\definecolor{uwmetalicgoldrgb}{rgb}{.57,.48,.30} % RGB 255    = (145,123,76)                              
\definecolor{uwlightgray}{rgb}{.85,.85,.85}      % HEX d9d9d9 = (217,217,217)                             
\definecolor{uwlightgrayrgb}{rgb}{.85,.85,.85}   % RGB 255    = (216,217,218)                             
\definecolor{uwdarkgray}{rgb}{.27,.27,.27}       % HEX 444444 = (68,68,68)                                
\definecolor{uwdarkgrayrgb}{rgb}{.60,.60,.60}    % RGB 255    = (153,153,153)

The hex colors work best for screens, like if your PDF will be viewed on a monitor. The RGB colors work best for print (I think I mistakenly used the hex colors in my printed dissertation and they were too light, but they look good in the PDF). But maybe you'll want to define your own colors?

I think you'll need to import the xcolor package. See here.

@oepen , can we rename the page https://github.com/delph-in/docs/wiki/LtgOslo_LaTeX to something more general like LateX and add these infos from @goodmami there?