source: doc/theses/andrew_beach_MMath/cfalab.sty @ 1dfe6a6

arm-ehjacob/cs343-translationnew-ast-unique-expr
Last change on this file since 1dfe6a6 was 6e7b969, checked in by Andrew Beach <ajbeach@…>, 11 months ago

Andrew MMath: First draft of existing features and updated framework.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1% Package for CFA Research Lab.
2%
3% Made by combining and updating various macro files people had made.
4%
5% Internal commands are prefixed with "\cfalab@".
6
7% I don't know what the oldest LaTeX2e version with everything needed is.
8\NeedsTeXFormat{LaTeX2e}
9\ProvidesPackage{cfalab}[2020/03/24 v0.1 CFA Laboratory LaTeX Tools]
10
11% Other packages required.
12\RequirePackage{etoolbox}
13\RequirePackage{listings}
14\RequirePackage{xspace}
15
16% Symbols: All symbols are zero argument robust commands with special rules
17% about the space following the c.s. token. Normally the space might be
18% re-added according to the rules of the xspace package. They may be followed
19% by a star (which the command will consume) to disable this behaviour.
20
21% \newsymbolcmd{<command>}{<replacement text>}
22%     Defines <command> to be a symbol that has the given <replacement text>.
23\newrobustcmd*\newsymbolcmd[2]{\newrobustcmd{#1}{\cfalab@symbol{#2}}}
24\def\cfalab@symbol#1{\@ifnextchar*{#1\cfalab@eatstar}{#1\xspace}}
25\def\cfalab@eatstar*{}
26
27% Cforall with the forall symbol.
28\newsymbolcmd\CFA{\textsf{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}}
29% C++ with kerning. (No standard number support.)
30\newsymbolcmd\CPP{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}}
31
32% This is executed very early in the \begin{document} code.
33\AtEndPreamble{
34  \@ifpackageloaded{hyperref}{
35    % Convert symbols to pdf compatable forms when required.
36    \pdfstringdefDisableCommands{
37      \def\CFA{CFA}
38      \def\CPP{C++}
39    }
40  }{}
41}
42
43% The CFA listings language. Based off of ANCI C and including GCC extensions.
44% The UW dialect is the default (and only so far) dialect of the language.
45\lstdefinelanguage[UW]{CFA}[ANSI]{C}{
46    morekeywords={_Alignas, _Alignof, __alignof, __alignof__, asm, __asm,
47        __asm__, __attribute, __attribute__, auto, _Bool, catch, catchResume,
48        choose, _Complex, __complex, __complex__, __const, __const__,
49        coroutine, disable, dtype, enable, exception, __extension__,
50        fallthrough, fallthru, finally, __float80, float80, __float128,
51        float128, forall, ftype, generator, _Generic, _Imaginary, __imag,
52        __imag__, inline, __inline, __inline__, __int128, int128, __label__,
53        monitor, mutex, _Noreturn, one_t, or, otype, restrict, resume,
54        __restrict, __restrict__, __signed, __signed__, _Static_assert,
55        suspend, thread, _Thread_local, throw, throwResume, timeout, trait,
56        try, ttype, typeof, __typeof, __typeof__, virtual, __volatile,
57        __volatile__, waitfor, when, with, zero_t
58    },
59    moredirectives={defined,include_next},
60}
61\lstset{defaultdialect={[UW]CFA}}
62
63% The cfalab style defines some common settings useful in different languages.
64\lstdefinestyle{cfalab}{%
65    columns=fullflexible,
66    basicstyle=\linespread{0.9}\tt,
67    stringstyle=\tt,
68}
69
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}
76
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}}}
86
87\endinput
Note: See TracBrowser for help on using the repository browser.