source: doc/LaTeXmacros/common.tex @ 1da317b

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 1da317b was 45576af9, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

update user manual and global latex macros

  • Property mode set to 100644
File size: 9.9 KB
Line 
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -*- Mode: Latex -*- %%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%%
3%% Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
4%%
5%% The contents of this file are covered under the licence agreement in the
6%% file "LICENCE" distributed with Cforall.
7%%
8%% common.tex --
9%%
10%% Author           : Peter A. Buhr
11%% Created On       : Sat Apr  9 10:06:17 2016
12%% Last Modified By : Peter A. Buhr
13%% Last Modified On : Fri Jun 10 16:35:25 2016
14%% Update Count     : 101
15%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16
17%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18
19\setlength{\textheight}{9in}
20%\oddsidemargin 0.0in
21\renewcommand{\topfraction}{0.8}        % float must be greater than X of the page before it is forced onto its own page
22\renewcommand{\bottomfraction}{0.8}     % float must be greater than X of the page before it is forced onto its own page
23\renewcommand{\floatpagefraction}{0.8}  % float must be greater than X of the page before it is forced onto its own page
24\renewcommand{\textfraction}{0.0}       % the entire page maybe devoted to floats with no text on the page at all
25\usepackage{pslatex}                            % reduce size of san serif font
26
27% Names used in the document.
28
29\newcommand{\CFA}{C$\mathbf\forall$\xspace}              % set language symbolic name
30\newcommand{\CFL}{Cforall\xspace}                        % set language text name
31\newcommand{\CC}{C\kern-.1em\hbox{+\kern-.25em+}\xspace} % CC symbolic name
32\def\c11{ISO/IEC C} % C11 name (cannot have numbers in latex command name)
33
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35
36\makeatletter
37% parindent is relative, i.e., toggled on/off in environments like itemize,
38% so store the value for use rather than use \parident directly.
39\newlength{\parindentlength}
40\setlength{\parindentlength}{\parindent}
41
42% allow escape sequence in lstinline
43%\usepackage{etoolbox}
44%\patchcmd{\lsthk@TextStyle}{\let\lst@DefEsc\@empty}{}{}{\errmessage{failed to patch}}
45
46% make fontsize "small" slightly larger, specifically for san serif (helvetica) in program code
47%\renewcommand\small{%
48%   \@setfontsize\small{8.5}{11}%
49%   \abovedisplayskip 8.5pt \@plus 3pt \@minus 4pt
50%   \abovedisplayshortskip \z@ \@plus 2pt
51%   \belowdisplayshortskip 4pt \@plus 2pt \@minus 2pt
52%   \def\@listi{\leftmargin\leftmargini
53%               \topsep 4pt \@plus 2pt \@minus 2pt
54%               \parsep 2pt \@pluspt \@minuspt
55%               \itemsep \parsep}%
56%   \belowdisplayskip \abovedisplayskip
57%}
58
59\usepackage{pslatex}                                                                    % reduce size of san serif font
60\usepackage{relsize}                                    % must be after change to small or selects old size
61
62% reduce size of chapter/section titles
63\def\@makechapterhead#1{%
64  \vspace*{50\p@}%
65  {\parindent \z@ \raggedright \normalfont
66    \ifnum \c@secnumdepth >\m@ne
67        \large\bfseries \@chapapp\space \thechapter
68        \par\nobreak
69        \vskip 5\p@
70    \fi
71    \interlinepenalty\@M
72    \Large \bfseries #1\par\nobreak
73    \vskip 50\p@
74  }}
75\def\@makeschapterhead#1{%
76  \vspace*{50\p@}%
77  {\parindent \z@ \raggedright
78    \normalfont
79    \interlinepenalty\@M
80    \Large \bfseries  #1\par\nobreak
81    \vskip 50\p@
82  }}
83\renewcommand\section{\@startsection{section}{1}{\z@}{-3.5ex \@plus -1ex \@minus -.2ex}{1.75ex \@plus .2ex}{\normalfont\large\bfseries}}
84\renewcommand\subsection{\@startsection{subsection}{2}{\z@}{-3.25ex \@plus -1ex \@minus -.2ex}{1.5ex \@plus .2ex}{\normalfont\normalsize\bfseries}}
85\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}{-2.5ex \@plus -1ex \@minus -.2ex}{1.0ex \@plus .2ex}{\normalfont\normalsize\bfseries}}
86\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}{-2.0ex \@plus -1ex \@minus -.2ex}{-1em}{\normalfont\normalsize\bfseries}}
87
88% index macros
89\newcommand{\italic}[1]{\emph{\hyperpage{#1}}}
90\newcommand{\definition}[1]{\textbf{\hyperpage{#1}}}
91\newcommand{\see}[1]{\emph{see} #1}
92
93% reduce bullet size and spacing for "itemize" macro
94\renewcommand{\labelitemi}{{\raisebox{0.25ex}{\footnotesize$\bullet$}}}
95\renewenvironment{itemize}{\begin{list}{\labelitemi}{\topsep=5pt\itemsep=5pt\parsep=0pt}}{\end{list}}
96
97% Define some commands that produce formatted index entries suitable for cross-references.
98% ``\spec'' produces entries for specifications of entities.  ``\impl'' produces entries for their
99% implementations, and ``\use'' for their uses.
100
101%  \newcommand{\bold}[1]{{\bf #1}}
102%  \def\spec{\@bsphack\begingroup
103%             \def\protect##1{\string##1\space}\@sanitize
104%             \@wrxref{|bold}}
105\def\impl{\@bsphack\begingroup
106          \def\protect##1{\string##1\space}\@sanitize
107          \@wrxref{|definition}}
108\newcommand{\indexcode}[1]{{\lstinline$#1$}}
109\def\use{\@bsphack\begingroup
110         \def\protect##1{\string##1\space}\@sanitize
111         \@wrxref{|hyperpage}}
112\def\@wrxref#1#2{\let\thepage\relax
113    \xdef\@gtempa{\write\@indexfile{\string
114    \indexentry{#2@{\lstinline$#2$}#1}{\thepage}}}\endgroup\@gtempa
115    \if@nobreak \ifvmode\nobreak\fi\fi\@esphack}
116%\newcommand{\use}[1]{\index{#1@{\lstinline$#1$}}}
117%\newcommand{\impl}[1]{\index{\protect#1@{\lstinline$\protect#1$}|definition}}
118
119% inline text and lowercase index: \Index{inline and lowercase index text}
120% inline text and as-in index: \Index[as-is index text]{inline text}
121% inline text but index with different as-is text: \Index[index text]{inline text}
122\newcommand{\Index}{\@ifstar\@sIndex\@Index}
123\newcommand{\@Index}[2][\@empty]{\lowercase{\def\temp{#2}}#2\ifx#1\@empty\index{\temp}\else\index{#1@{\protect#2}}\fi}
124\newcommand{\@sIndex}[2][\@empty]{#2\ifx#1\@empty\index{#2}\else\index{#1@{\protect#2}}\fi}
125
126\newcommand{\Indexc}[1]{\lstinline$#1$\index{#1@\lstinline$#1$}}
127\newcommand{\indexc}[1]{\index{#1@\lstinline$#1$}}
128
129\newcommand{\newtermFontInline}{\emph}
130\newcommand{\newterm}{\@ifstar\@snewterm\@newterm}
131\newcommand{\@newterm}[2][\@empty]{\lowercase{\def\temp{#2}}{\newtermFontInline{#2}}\ifx#1\@empty\index{\temp}\else\index{#1@{\protect#2}}\fi}
132\newcommand{\@snewterm}[2][\@empty]{{\newtermFontInline{#2}}\ifx#1\@empty\index{#2}\else\index{#1@{\protect#2}}\fi}
133\makeatother
134
135\newenvironment{quote2}{%
136        \list{}{\lstset{resetmargins=true,aboveskip=0pt,belowskip=0pt}\topsep=4pt\parsep=0pt\leftmargin=\parindent\rightmargin\leftmargin}%
137        \item\relax
138}{%
139        \endlist
140}% quote2
141\newenvironment{rationale}{%
142  \begin{quotation}\noindent$\Box$\enspace
143}{%
144  \hfill\enspace$\Box$\end{quotation}
145}%
146
147% blocks and titles
148\newcommand{\define}[1]{\emph{#1\/}\index{#1}}
149\newcommand{\rewriterules}{\paragraph{Rewrite Rules}~\par\noindent}
150\newcommand{\examples}{\paragraph{Examples}~\par\noindent}
151\newcommand{\semantics}{\paragraph{Semantics}~\par\noindent}
152\newcommand{\constraints}{\paragraph{Constraints}~\par\noindent}
153\newcommand{\predefined}{\paragraph{Predefined Identifiers}~\par\noindent}
154
155% BNF macros
156\def\syntax{\paragraph{Syntax}\trivlist\parindent=.5in\item[\hskip.5in]}
157\let\endsyntax=\endtrivlist
158\newcommand{\lhs}[1]{\par{\emph{#1:}}\index{#1@{\emph{#1}}|italic}}
159\newcommand{\rhs}{\hfil\break\hbox{\hskip1in}}
160\newcommand{\oldlhs}[1]{\emph{#1: \dots}\index{#1@{\emph{#1}}|italic}}
161\newcommand{\nonterm}[1]{\emph{#1\/}\index{#1@{\emph{#1}}|italic}}
162\newcommand{\opt}{$_{opt}$\ }
163
164% adjust varioref package with default "section" and "page" titles, and optional title with faraway page numbers
165% \VRef{label} => Section 2.7, \VPageref{label} => page 17
166% \VRef[Figure]{label} => Figure 3.4, \VPageref{label} => page 17
167\renewcommand{\reftextfaceafter}{\unskip}
168\renewcommand{\reftextfacebefore}{\unskip}
169\renewcommand{\reftextafter}{\unskip}
170\renewcommand{\reftextbefore}{\unskip}
171\renewcommand{\reftextfaraway}[1]{\unskip, p.~\pageref{#1}}
172\renewcommand{\reftextpagerange}[2]{\unskip, pp.~\pageref{#1}--\pageref{#2}}
173\newcommand{\VRef}[2][Section]{\ifx#1\@empty\else{#1}\nobreakspace\fi\vref{#2}}
174\newcommand{\VPageref}[2][page]{\ifx#1\@empty\else{#1}\nobreakspace\fi\pageref{#2}}
175
176% Go programming language
177\lstdefinelanguage{Golang}{
178        morekeywords=[1]{package,import,func,type,struct,return,defer,panic, recover,select,var,const,iota,},%
179        morekeywords=[2]{string,uint,uint8,uint16,uint32,uint64,int,int8,int16, int32,int64,
180                bool,float32,float64,complex64,complex128,byte,rune,uintptr, error,interface},%
181        morekeywords=[3]{map,slice,make,new,nil,len,cap,copy,close,true,false, delete,append,real,imag,complex,chan,},%
182        morekeywords=[4]{for,break,continue,range,goto,switch,case,fallthrough,if, else,default,},%
183        morekeywords=[5]{Println,Printf,Error,},%
184        sensitive=true,%
185        morecomment=[l]{//},%
186        morecomment=[s]{/*}{*/},%
187        morestring=[b]',%
188        morestring=[b]",%
189        morestring=[s]{`}{`},%
190}
191
192% CFA programming language, based on ANSI C
193\lstdefinelanguage{CFA}[ANSI]{C}{
194        morekeywords={_Alignas,_Alignof,__alignof,__alignof__,asm,__asm,__asm__,_At,_Atomic,__attribute,__attribute__,auto,
195                _Bool,catch,catchResume,choose,_Complex,__complex,__complex__,__const,__const__,disable,dtype,enable,__extension__,
196                fallthru,finally,forall,ftype,_Generic,_Imaginary,inline,__label__,lvalue,_Noreturn,otype,restrict,_Static_assert,
197                _Thread_local,throw,throwResume,trait,try,typeof,__typeof,__typeof__,},
198}%
199
200\lstset{
201language=CFA,
202columns=flexible,
203basicstyle=\linespread{0.9}\sf,
204stringstyle=\tt,
205tabsize=4,
206xleftmargin=\parindentlength,
207extendedchars=true,
208escapechar=§,
209mathescape=true,
210keepspaces=true,
211showstringspaces=false,
212showlines=true,
213aboveskip=4pt,
214belowskip=3pt,
215moredelim=**[is][\color{red}]{®}{®}, % red highlighting
216moredelim=**[is][\color{blue}]{ß}{ß}, % blue highlighting
217moredelim=**[is][\color{OliveGreen}]{¢}{¢}, % green highlighting
218moredelim=[is][\lstset{keywords={}}]{}{}, % temporarily turn off keywords
219% replace/adjust listing characters that look bad in sanserif
220literate={-}{\raisebox{-0.15ex}{\texttt{-}}}1 {^}{\raisebox{0.6ex}{$\scriptscriptstyle\land\,$}}1
221        {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 {_}{\makebox[1.2ex][c]{\rule{1ex}{0.1ex}}}1 {`}{\ttfamily\upshape\hspace*{-0.1ex}`}1
222        {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {...}{$\dots$}2,
223}%
224
225\lstMakeShortInline©    % single-character for \lstinline
226
227% Local Variables: %
228% tab-width: 4 %
229% fill-column: 100 %
230% End: %
Note: See TracBrowser for help on using the repository browser.