Changeset 8d66610 for doc/theses/andrew_beach_MMath/cfalab.sty
- Timestamp:
- May 21, 2021, 4:48:10 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
- Children:
- f1bce515
- Parents:
- 5407cdc (diff), 7404cdc (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
doc/theses/andrew_beach_MMath/cfalab.sty (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/andrew_beach_MMath/cfalab.sty
r5407cdc r8d66610 1 1 % Package for CFA Research Lab. 2 % (Now more a personal collection and testing grounds for common.sty.) 2 3 % 3 % Made by combining and updating various macro files people had made. 4 % This is a collection of commands everyone working on CFA related documents 5 % should find useful. So mostly programming language related tools. 4 6 % 5 7 % Internal commands are prefixed with "\cfalab@". … … 10 12 11 13 % Other packages required. 14 % 15 % Access to new basic LaTeX tools and other low level commands. 12 16 \RequirePackage{etoolbox} 17 % Code formatting tools and environments. 13 18 \RequirePackage{listings} 19 % Automatically adds spaces. 14 20 \RequirePackage{xspace} 15 21 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. 22 % Tip for commands that end with \xspace: if the default is not correct then 23 % follow the command with {} to disable \xspace, use '{} ' to force add a 24 % space and '{}<whatever-follows>' to force remove one. 25 % 26 % \CFA 27 % Cforall with the forall symbol. 28 \newrobustcmd\CFA{\textsf{C\raisebox{\depth}{\rotatebox{180}{A}}}\xspace} 29 % \Cpp[<std>] 30 % C++ symbol name. You may optionally provide <std> to specify a standard. 31 \newrobustcmd\Cpp[1][\xspace]{C++#1} 20 32 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 % This is executed very early in the \begin{document} code, before the 34 % document's contents but after packages are loaded. 33 35 \AtEndPreamble{ 34 36 \@ifpackageloaded{hyperref}{ … … 36 38 \pdfstringdefDisableCommands{ 37 39 \def\CFA{CFA} 38 \def\CPP{C++} 40 \def\Cpp{C++} 41 \def\lstinline{} 42 \def\code#1#2{#2} 39 43 } 40 44 }{} 41 45 } 46 47 % \colour{<colour>}{<text>} 48 % Just \color but using the LaTeX style instead of TeX style command. 49 \newcommand*\colour[2]{{\color{#1}#2}} 50 51 % \code{<language>}{<code>} 52 % Use the listings package to format the snipit of <code> in <language>. 53 \newrobustcmd*\code[2]{\lstinline[language=#1]{#2}} 54 55 % \begin{cfa}[<options>] 56 % \end{cfa} 57 % Use the listings package to format a block of CFA code. 58 % Extra listings options can be passed in as an optional argument. 59 \lstnewenvironment{cfa}[1][]{\lstset{language=CFA}\lstset{#1}}{} 60 61 % \settextunderscore{(new|old)} 62 % Redefines the underscore either as a new repersentation or the old one. 63 % Not that some other packages (ex. hyperref) can override this. Set it up 64 % after loading them. 65 \let\cfalab@textunderscore@old=\textunderscore 66 \newcommand\cfalab@textunderscore@new{% 67 \leavevmode\makebox[1.2ex][c]{\rule{1ex}{0.075ex}}} 68 \newcommand\settextunderscore[1]{% 69 \renewcommand\textunderscore{\csuse{cfalab@textunderscore@#1}}} 42 70 43 71 % The CFA listings language. Based off of ANCI C and including GCC extensions. … … 61 89 \lstset{defaultdialect={[UW]CFA}} 62 90 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, 91 % Create an internal paragraph indent amount. This is used internally to 92 % mimic the standard indent even when it has been overriden in the document. 93 \newlength\cfalab@parindent 94 \deflength\cfalab@parindent{\parindent} 95 96 % The cfacommon style has many useful defaults for CFA and other types of 97 % code. Use the listings option "style=cfacommon" to load them. 98 \lstdefinestyle{cfacommon}{ 99 columns=fullflexible, 100 basicstyle=\linespread{0.9}\sf, 101 stringstyle=\tt, 102 tabsize=5, 103 % Indent code to paragraph indentation. 104 xleftmargin=\cfalab@parindent, 105 % Allow ASCII characters in the range 128-255. 106 extendedchars=true, 107 % This allows you to use "math mode" to insert LaTeX into the code. 108 % Use \( and \) if you need to insert math mode inside that code. 109 escapechar=\$, 110 % Disable LaTeX math escape in CFA code $...$ 111 mathescape=false, 112 keepspaces=true, 113 % Do not show spaces with cup. 114 showstringspaces=false, 115 % Show blank lines at end of code. 116 showlines=true, 117 % Spacing above/below code block. 118 aboveskip=4pt,belowskip=0pt, 119 numberstyle=\footnotesize\sf, 120 % Replace/adjust listing characters that look bad in sanserif. 121 literate={-}{\makebox[1ex][c]{\raisebox{0.7ex}{\rule{0.75ex}{0.1ex}}}}1 122 {^}{\raisebox{0.6ex}{$\scriptscriptstyle\land\,$}}1 123 {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 {`}{\ttfamily\upshape\hspace*{-0.1ex}`}1 124 {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 125 {->}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex\textgreater}2, 68 126 } 69 127 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} 128 % common.tex Compatablity =================================================== 129 % Below this line is for compatability with the old common.tex file. 76 130 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}}} 131 % Backwards compatable way to activate the cfacommon style. 132 \newcommand{\CFAStyle}{\lstset{style=cfacommon}} 133 134 % A couple of abbreviations are provided. Just ones someone liked. 135 % 136 % Abbreviation formatting commands (renew to customize): 137 \newcommand{\abbrevFont}{\textit} 138 % 139 % Abbreviations that, if not followed by a comma or colon, add a comma. 140 \newrobustcmd*\cfalab@abbrev@comma{% 141 \@ifnextchar{,}{}{\@ifnextchar{:}{}{,\xspace}}} 142 \providerobustcmd*\eg{\abbrevFont{e}.\abbrevFont{g}.\cfalab@abbrev@comma} 143 \providerobustcmd*\ie{\abbrevFont{i}.\abbrevFont{e}.\cfalab@abbrev@comma} 144 % 145 % Abbreviations that, if not followed by a period, add a period. 146 \newrobustcmd*\cfalab@abbrev@period{\@ifnextchar{.}{}{.\xspace}} 147 \providerobustcmd*\etc{\abbrevFont{etc}\cfalab@abbrev@period} 148 \providerobustcmd*\etal{\abbrevFont{et}~\abbrevFont{al}\cfalab@abbrev@period} 149 \providerobustcmd*\viz{\abbrevFont{viz}\cfalab@abbrev@period} 86 150 87 151 \endinput
Note:
See TracChangeset
for help on using the changeset viewer.