Ignore:
Timestamp:
Apr 26, 2021, 4:37:36 PM (7 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
edc6ea2
Parents:
5456537
Message:

Andrew MMath: Switch from common.tex to cfalab.sty. Still work to do but it is almost everything I had before.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/andrew_beach_MMath/cfalab.sty

    r5456537 rdf24d37  
    1010
    1111% Other packages required.
     12%
     13% Access to new basic LaTeX tools and other low level commands.
    1214\RequirePackage{etoolbox}
     15% Code formatting tools and environments.
    1316\RequirePackage{listings}
     17% Automatically adds spaces.
    1418\RequirePackage{xspace}
     19% Improved reference tools.
     20\RequirePackage[nospace]{varioref}
    1521
    1622% Symbols: All symbols are zero argument robust commands with special rules
     
    2834\newsymbolcmd\CFA{\textsf{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}}
    2935% C++ with kerning. (No standard number support.)
    30 \newsymbolcmd\CPP{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}}
     36\newsymbolcmd\Cpp{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}}
    3137
    32 % This is executed very early in the \begin{document} code.
     38% This is executed very early in the \begin{document} code, before the
     39% document's contents but after packages are loaded.
    3340\AtEndPreamble{
    3441  \@ifpackageloaded{hyperref}{
     
    3643    \pdfstringdefDisableCommands{
    3744      \def\CFA{CFA}
    38       \def\CPP{C++}
     45      \def\Cpp{C++}
     46      \def\lstinline{}
    3947    }
    4048  }{}
    4149}
     50
     51% \colour{<colour>}{<text>}
     52% Just \colour but using the LaTeX style instead of TeX style command.
     53\newcommand*\colour[2]{{\color{#1}#2}}
     54
     55% \code*{<code>}
     56% Use the listings package to format a snipit of <code>.
     57\newrobustcmd*\codeCFA[1]{\lstinline[language=CFA]{#1}}
     58\newrobustcmd*\codeC[1]{\lstinline[language=C]{#1}}
     59\newrobustcmd*\codeCpp[1]{\lstinline[language=C++]{#1}}
     60\newrobustcmd*\codePy[1]{\lstinline[language=Python]{#1}}
     61
     62\lstnewenvironment{cfa}[1][]{\lstset{language=CFA}\lstset{#1}}{}
     63
     64% \settextunderscore{(new|old)}
     65% Redefines the underscore either as a new repersentation or the old one.
     66% Not that some other packages (ex. hyperref) can override this. Set it up
     67% after loading them.
     68\let\cfalab@textunderscore@old=\textunderscore
     69\newcommand\cfalab@textunderscore@new{%
     70    \leavevmode\makebox[1.2ex][c]{\rule{1ex}{0.075ex}}}
     71\newcommand\settextunderscore[1]{%
     72    \renewcommand\textunderscore{\csuse{cfalab@textunderscore@#1}}}
    4273
    4374% The CFA listings language. Based off of ANCI C and including GCC extensions.
     
    6899}
    69100
    70 % \code*[<escape character>]{<code>}
    71 %     Use the listings package to format a snipit of <code>.
    72 %     The <escape character> must be a character that does not appear in
    73 %     <code> and defaults to a backtick.
    74 \newcommand*\codeC[2][\`]{\lstinline[language=C]#1#2#1}
    75 \newcommand*\codeCFA[2][\`]{\lstinline[language=CFA]#1#2#1}
     101% common.tex Compatablity ===================================================
     102% Below this line is for compatability with the old common.tex file.
    76103
    77 % \settextunderscore{(new|old)}
    78 %     Redefines the underscore either as a new repersentation or the old one.
    79 %     Not that some other packages (ex. hyperref) can override this. Set it
    80 %     up after loading them.
    81 \let\cfalab@textunderscore@old=\textunderscore
    82 \newcommand\cfalab@textunderscore@new{%
    83     \leavevmode\makebox[1.2ex][c]{\rule{1ex}{0.075ex}}}
    84 \newcommand\settextunderscore[1]{%
    85     \renewcommand\textunderscore{\csuse{cfalab@textunderscore@#1}}}
     104\newcommand{\CFAStyle}{%
     105  \lstset{
     106    columns=fullflexible,
     107    % reduce line spacing and use sanserif font
     108    basicstyle=\linespread{0.9}\sf,
     109    % use typewriter font
     110    stringstyle=\tt,
     111    tabsize=5,
     112    % indent code to paragraph indentation
     113    %xleftmargin=\parindentlnth,
     114    % Allow ASCII characters in the range 128-255.
     115    extendedchars=true,
     116    % This allows you to use "math mode" to insert LaTeX into the code.
     117    % Use \( and \) if you need to insert math mode inside that code.
     118    escapechar=\$,
     119    % LaTeX math escape in CFA code $...$
     120    mathescape=false,
     121    keepspaces=true,
     122    % do not show spaces with cup
     123    showstringspaces=false,
     124    % show blank lines at end of code
     125    showlines=true,
     126    aboveskip=4pt,                          % spacing above/below code block
     127    belowskip=0pt,
     128    % numbering style
     129    numberstyle=\footnotesize\sf,
     130    % replace/adjust listing characters that look bad in sanserif
     131    literate={-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.75ex}{0.1ex}}}}1
     132      {^}{\raisebox{0.6ex}{$\scriptscriptstyle\land\,$}}1
     133      {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 {`}{\ttfamily\upshape\hspace*{-0.1ex}`}1
     134      {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2
     135      {->}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex\textgreater}2,
     136  }
     137}
     138
     139\newcommand{\abbrevFont}{\textit}           % set empty for no italics
     140\@ifundefined{eg}{
     141\newcommand{\EG}{\abbrevFont{e}.\abbrevFont{g}.}
     142\newcommand*{\eg}{%
     143    \@ifnextchar{,}{\EG}%
     144        {\@ifnextchar{:}{\EG}%
     145            {\EG,\xspace}}%
     146}}{}%
     147\@ifundefined{ie}{
     148\newcommand{\IE}{\abbrevFont{i}.\abbrevFont{e}.}
     149\newcommand*{\ie}{%
     150    \@ifnextchar{,}{\IE}%
     151        {\@ifnextchar{:}{\IE}%
     152            {\IE,\xspace}}%
     153}}{}%
     154\@ifundefined{etc}{
     155\newcommand{\ETC}{\abbrevFont{etc}}
     156\newcommand*{\etc}{%
     157    \@ifnextchar{.}{\ETC}%
     158        {\ETC.\xspace}%
     159}}{}%
     160\@ifundefined{etal}{
     161\newcommand{\ETAL}{\abbrevFont{et}~\abbrevFont{al}}
     162\newcommand*{\etal}{%
     163    \@ifnextchar{.}{\protect\ETAL}%
     164        {\protect\ETAL.\xspace}%
     165}}{}%
     166\@ifundefined{viz}{
     167\newcommand{\VIZ}{\abbrevFont{viz}}
     168\newcommand*{\viz}{%
     169    \@ifnextchar{.}{\VIZ}%
     170        {\VIZ.\xspace}%
     171}}{}%
    86172
    87173\endinput
Note: See TracChangeset for help on using the changeset viewer.