source: doc/theses/andrew_beach_MMath/cfalab.sty @ c0c940a

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since c0c940a was c0c940a, checked in by Peter A. Buhr <pabuhr@…>, 3 years ago

fix conflicit

  • Property mode set to 100644
File size: 6.0 KB
RevLine 
[2c052c0]1% Package for CFA Research Lab.
2%
[a049412]3% This is a collection of commands everyone working on CFA related documents
4% should find useful. So mostly programming language related tools.
[c72ea7a]5%
6% Internal commands are prefixed with "\cfalab@".
[2c052c0]7
8% I don't know what the oldest LaTeX2e version with everything needed is.
9\NeedsTeXFormat{LaTeX2e}
[c72ea7a]10\ProvidesPackage{cfalab}[2020/03/24 v0.1 CFA Laboratory LaTeX Tools]
[2c052c0]11
12% Other packages required.
[df24d37]13%
14% Access to new basic LaTeX tools and other low level commands.
[2c052c0]15\RequirePackage{etoolbox}
[df24d37]16% Code formatting tools and environments.
[c72ea7a]17\RequirePackage{listings}
[df24d37]18% Automatically adds spaces.
[2c052c0]19\RequirePackage{xspace}
20
[a049412]21% Tip for commands that end with \xspace: if the default is not correct then
22% follow the command with {} to disable \xspace, use '{} ' to force add a
23% space and '{}<whatever-follows>' to force remove one.
24%
[2c052c0]25% Cforall with the forall symbol.
[a049412]26\newrobustcmd\CFA{\textsf{C\raisebox{\depth}{\rotatebox{180}{A}}}\xspace}
27% C++ with kerning. You may optionally append a standard number.
28\newrobustcmd\Cpp[1][\xspace]{C++#1}
[6e7b969]29
[df24d37]30% This is executed very early in the \begin{document} code, before the
31% document's contents but after packages are loaded.
[6e7b969]32\AtEndPreamble{
33  \@ifpackageloaded{hyperref}{
34    % Convert symbols to pdf compatable forms when required.
35    \pdfstringdefDisableCommands{
36      \def\CFA{CFA}
[df24d37]37      \def\Cpp{C++}
38      \def\lstinline{}
[6e7b969]39    }
40  }{}
41}
[2c052c0]42
[df24d37]43% \colour{<colour>}{<text>}
[edc6ea2]44% Just \color but using the LaTeX style instead of TeX style command.
[df24d37]45\newcommand*\colour[2]{{\color{#1}#2}}
46
47% \code*{<code>}
48% Use the listings package to format a snipit of <code>.
49\newrobustcmd*\codeCFA[1]{\lstinline[language=CFA]{#1}}
50\newrobustcmd*\codeC[1]{\lstinline[language=C]{#1}}
51\newrobustcmd*\codeCpp[1]{\lstinline[language=C++]{#1}}
52\newrobustcmd*\codePy[1]{\lstinline[language=Python]{#1}}
53
[edc6ea2]54% Use the listings package to format a block of CFA code.
55% Extra listings options can be passed in as an optional argument.
[df24d37]56\lstnewenvironment{cfa}[1][]{\lstset{language=CFA}\lstset{#1}}{}
57
58% \settextunderscore{(new|old)}
59% Redefines the underscore either as a new repersentation or the old one.
60% Not that some other packages (ex. hyperref) can override this. Set it up
61% after loading them.
62\let\cfalab@textunderscore@old=\textunderscore
63\newcommand\cfalab@textunderscore@new{%
64    \leavevmode\makebox[1.2ex][c]{\rule{1ex}{0.075ex}}}
65\newcommand\settextunderscore[1]{%
66    \renewcommand\textunderscore{\csuse{cfalab@textunderscore@#1}}}
67
[c72ea7a]68% The CFA listings language. Based off of ANCI C and including GCC extensions.
69% The UW dialect is the default (and only so far) dialect of the language.
70\lstdefinelanguage[UW]{CFA}[ANSI]{C}{
71    morekeywords={_Alignas, _Alignof, __alignof, __alignof__, asm, __asm,
72        __asm__, __attribute, __attribute__, auto, _Bool, catch, catchResume,
73        choose, _Complex, __complex, __complex__, __const, __const__,
74        coroutine, disable, dtype, enable, exception, __extension__,
75        fallthrough, fallthru, finally, __float80, float80, __float128,
76        float128, forall, ftype, generator, _Generic, _Imaginary, __imag,
77        __imag__, inline, __inline, __inline__, __int128, int128, __label__,
78        monitor, mutex, _Noreturn, one_t, or, otype, restrict, resume,
79        __restrict, __restrict__, __signed, __signed__, _Static_assert,
80        suspend, thread, _Thread_local, throw, throwResume, timeout, trait,
81        try, ttype, typeof, __typeof, __typeof__, virtual, __volatile,
82        __volatile__, waitfor, when, with, zero_t
83    },
84    moredirectives={defined,include_next},
85}
86\lstset{defaultdialect={[UW]CFA}}
87
[c1136c56]88% Create an internal paragraph indent amount. This is used internally to
89% mimic the standard indent even when it has been overriden in the document.
90\newlength\cfalab@parindent
91\deflength\cfalab@parindent{\parindent}
92
93% The cfacommon style has many useful defaults for CFA and other types of
94% code. Use the listings option "style=cfacommon" to load them.
95\lstdefinestyle{cfacommon}{
96  columns=fullflexible,
97  basicstyle=\linespread{0.9}\sf,
98  stringstyle=\tt,
99  tabsize=5,
100  % Indent code to paragraph indentation.
101  xleftmargin=\cfalab@parindent,
102  % Allow ASCII characters in the range 128-255.
103  extendedchars=true,
104  % This allows you to use "math mode" to insert LaTeX into the code.
105  % Use \( and \) if you need to insert math mode inside that code.
106  escapechar=\$,
107  % Disable LaTeX math escape in CFA code $...$
108  mathescape=false,
109  keepspaces=true,
110  % Do not show spaces with cup.
111  showstringspaces=false,
112  % Show blank lines at end of code.
113  showlines=true,
114  % Spacing above/below code block.
115  aboveskip=4pt,belowskip=0pt,
116  numberstyle=\footnotesize\sf,
117  % Replace/adjust listing characters that look bad in sanserif.
[ec1c674]118  literate={-}{\makebox[1ex][c]{\raisebox{0.7ex}{\rule{0.75ex}{0.1ex}}}}1
[c1136c56]119    {^}{\raisebox{0.6ex}{$\scriptscriptstyle\land\,$}}1
120    {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 {`}{\ttfamily\upshape\hspace*{-0.1ex}`}1
121    {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2
122    {->}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex\textgreater}2,
[c72ea7a]123}
124
[df24d37]125% common.tex Compatablity ===================================================
126% Below this line is for compatability with the old common.tex file.
[c72ea7a]127
[c1136c56]128% Backwards compatable way to activate the cfacommon style.
129\newcommand{\CFAStyle}{\lstset{style=cfacommon}}
[df24d37]130
[edc6ea2]131% A couple of abbreviations are provided. Just ones someone liked.
132%
133% Abbreviation formatting commands (renew to customize):
134\newcommand{\abbrevFont}{\textit}
135%
136% Abbreviations that, if not followed by a comma or colon, add a comma.
137\newrobustcmd*\cfalab@abbrev@comma{%
138  \@ifnextchar{,}{}{\@ifnextchar{:}{}{,\xspace}}}
139\providerobustcmd*\eg{\abbrevFont{e}.\abbrevFont{g}.\cfalab@abbrev@comma}
140\providerobustcmd*\ie{\abbrevFont{i}.\abbrevFont{e}.\cfalab@abbrev@comma}
141%
142% Abbreviations that, if not followed by a period, add a period.
143\newrobustcmd*\cfalab@abbrev@period{\@ifnextchar{.}{}{.\xspace}}
144\providerobustcmd*\etc{\abbrevFont{etc}\cfalab@abbrev@period}
145\providerobustcmd*\etal{\abbrevFont{et}~\abbrevFont{al}\cfalab@abbrev@period}
146\providerobustcmd*\viz{\abbrevFont{viz}\cfalab@abbrev@period}
[2c052c0]147
148\endinput
Note: See TracBrowser for help on using the repository browser.