Skip to content

Commit

Permalink
Don't use \emph directly as markup of table headings
Browse files Browse the repository at this point in the history
This makes it easier to spot misuses of \emph, as well as giving us a single place for controlling the formatting of table headings.
  • Loading branch information
henrikt-ma committed Apr 30, 2020
1 parent 5196ece commit 097846b
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 62 deletions.
2 changes: 1 addition & 1 deletion chapters/annotations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1896,7 +1896,7 @@ \section{Annotations for Access Control to Protect Intellectual Property}\double
\textbf{Definitions:}
\begin{longtable}[]{|p{2.5cm}|p{12cm}|}
\hline
\emph{Term} & \emph{Description}\\ \hline
\tablehead{Term} & \tablehead{Description}\\ \hline
\endhead
\textbf{Protection} & Define what parts of a class are visible.\\
\hline
Expand Down
56 changes: 28 additions & 28 deletions chapters/arrays.tex
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ \section{Array Declarations}\doublelabel{array-declarations}
\begin{longtable}{|l|l|l|l|p{4cm}|}
\caption{General forms of declaration of arrays.}\\
\hline
\emph{Modelica form 1} & \emph{Modelica form 2} & \emph{\# dimensions} & \emph{Designation} & \emph{Explanation}\\ \hline
\tablehead{Modelica form 1} & \tablehead{Modelica form 2} & \tablehead{\# dimensions} & \tablehead{Designation} & \tablehead{Explanation}\\ \hline
\endhead
C x; & C x; & 0 & Scalar & Scalar\\ \hline
C{[}n{]} x; & C x{[}n{]}; & 1 & Vector & n -- Vector\\ \hline
Expand Down Expand Up @@ -122,8 +122,8 @@ \section{Array Declarations}\doublelabel{array-declarations}
\caption{Declaration of arrays as 1-vectors, row-vectors, or
column-vectors of arrays.}\\
\hline
\emph{Modelica form 1} & \emph{Modelica form 2} & \emph{\# dimensions} &
\emph{Designation} & \emph{Explanation}\\ \hline
\tablehead{Modelica form 1} & \tablehead{Modelica form 2} & \tablehead{\# dimensions} &
\tablehead{Designation} & \tablehead{Explanation}\\ \hline
\endhead
C{[}1{]} x; & C x{[}1{]}; & 1 & Vector & 1 -- Vector, representing a scalar\\ \hline
C{[}1,1{]} x; & C x{[}1, 1{]}; & 2 & Matrix & 1 x 1 -- Matrix, representing a scalar\\ \hline
Expand Down Expand Up @@ -245,7 +245,7 @@ \subsection{Array Dimension and Size Functions}\doublelabel{array-dimension-and-
\begin{longtable}[]{|l|p{9cm}|}
\caption{Built-in array dimension and size functions.}\\
\hline
\emph{Modelica} & \emph{Explanation}\\ \hline
\tablehead{Modelica} & \tablehead{Explanation}\\ \hline
\endhead
\lstinline!ndims(A)! &
Returns the number of dimensions $k$ of expression \lstinline!A!, with $k \geq 0$.
Expand All @@ -265,7 +265,7 @@ \subsection{Dimensionality Conversion Functions}\doublelabel{dimensionality-conv
\begin{longtable}[]{|l|p{9cm}|}
\caption{Built-in dimensionality conversion functions.}\\
\hline
\emph{Modelica} & \emph{Explanation}\\ \hline
\tablehead{Modelica} & \tablehead{Explanation}\\ \hline
\endhead
\lstinline!scalar(A)! & Returns the single element of array \lstinline!A!. $\text{\lstinline!size(A, i)!} = 1$ is required for $1
\leq \text{\lstinline!i!} \leq \text{\lstinline!ndims(A)!}$.\\ \hline
Expand Down Expand Up @@ -293,7 +293,7 @@ \subsection{Specialized Array Constructor Functions}\doublelabel{specialized-arr
\begin{longtable}[]{|l|p{11cm}|}
\caption{Specialized array constructor functions.}\\
\hline
\emph{Modelica} & \emph{Explanation}\\ \hline
\tablehead{Modelica} & \tablehead{Explanation}\\ \hline
\endhead
\lstinline!identity(n)!
&
Expand Down Expand Up @@ -346,7 +346,7 @@ \subsection{Reduction Functions and Operators}\doublelabel{reduction-functions-a
\begin{longtable}{|p{4.1cm}|p{10.1cm}|}
\caption{Array reduction functions and operators.}\\
\hline
\emph{Modelica} & \emph{Explanation}\\ \hline
\tablehead{Modelica} & \tablehead{Explanation}\\ \hline
\endhead
\lstinline!min(A)!
&
Expand Down Expand Up @@ -470,7 +470,7 @@ \subsubsection{Reduction Expressions}\doublelabel{reduction-expressions}
\begin{longtable}{|p{3cm}|p{5cm}|p{6cm}|}
\caption{Reduction expressions with iterators.}\\
\hline
\emph{Function-name} & \emph{Restriction on expression1} & \emph{Result if expression2 is empty}\\ \hline
\tablehead{Function-name} & \tablehead{Restriction on expression1} & \tablehead{Result if expression2 is empty}\\ \hline
\endhead
\lstinline!sum! & Integer or Real & \lstinline!zeros(...)!\\ \hline
\lstinline!product! & Scalar Integer or Real & \lstinline!1!\\ \hline
Expand Down Expand Up @@ -506,7 +506,7 @@ \subsection{Matrix and Vector Algebra Functions}\doublelabel{matrix-and-vector-a
\begin{longtable}[]{|p{3.5cm}|p{11.5cm}|}
\caption{Matrix and vector algebra functions.}\\
\hline
\emph{Modelica} & \emph{Explanation}\\ \hline
\tablehead{Modelica} & \tablehead{Explanation}\\ \hline
\endhead
\lstinline!transpose(A)!
& Permutes the first two dimensions of array A. It is an error, if array A
Expand Down Expand Up @@ -828,7 +828,7 @@ \section{Array Indexing}\doublelabel{array-indexing}
\begin{longtable}[]{|l|l|l|}
\caption{Examples of scalars vs. array slices created with the colon index.}\\
\hline
\emph{Expression} & \emph{\# dimensions} & \emph{Type of value}\\ \hline
\tablehead{Expression} & \tablehead{\# dimensions} & \tablehead{Type of value}\\ \hline
\endhead
\lstinline!x[1, 1]! & \lstinline!0! & Scalar\\ \hline
\lstinline!x[:, 1]! & \lstinline!1! & n -- Vector\\ \hline
Expand Down Expand Up @@ -897,7 +897,7 @@ \subsection{Equality and Assignment}\doublelabel{equality-and-assignment}
\begin{longtable}[]{|l|l|l|l|}
\caption{Equality and assignment of arrays and scalars.}\\
\hline
\emph{Type of a} & \emph{Type of b} & \emph{Result of} a = b & \emph{Operation} (j=1:n, k=1:m)\\ \hline
\tablehead{Type of a} & \tablehead{Type of b} & \tablehead{Result of} a = b & \tablehead{Operation} (j=1:n, k=1:m)\\ \hline
\endhead
Scalar & Scalar & Scalar & a = b\\ \hline
Vector{[}n{]} & Vector{[}n{]} & Vector{[}n{]} & a{[}j{]} =
Expand All @@ -921,8 +921,8 @@ \subsection{Array Element-wise Addition, Subtraction, and String Concatenation}\
\begin{longtable}[]{|l|l|l|l|}
\caption{Array addition, subtraction, and string concatenation.}\\
\hline
\emph{Type of a} & \emph{Type of b} & \emph{Result of a +/- b} &
\emph{Operation c := a +/- b (j=1:n, k=1:m)}\\ \hline
\tablehead{Type of a} & \tablehead{Type of b} & \tablehead{Result of a +/- b} &
\tablehead{Operation c := a +/- b (j=1:n, k=1:m)}\\ \hline
\endhead
Scalar & Scalar & Scalar & c := a +/- b\\ \hline
Vector{[}n{]} & Vector{[}n{]} & Vector{[}n{]} & c{[}j{]} := a{[}j{]} +/-
Expand All @@ -945,8 +945,8 @@ \subsection{Array Element-wise Addition, Subtraction, and String Concatenation}\
\begin{longtable}[]{|l|l|l|l|}
\caption{Array element-wise addition, subtraction, and string concatenation.}\\
\hline
\emph{Type of a} & \emph{Type of b} & \emph{Result of a} \lstinline!.+/.-! \emph{b}
& \emph{Operation c := a .+/.- b (j=1:n, k=1:m)}\\ \hline
\tablehead{Type of a} & \tablehead{Type of b} & \tablehead{Result of a} \lstinline!.+/.-! \tablehead{b}
& \tablehead{Operation c := a .+/.- b (j=1:n, k=1:m)}\\ \hline
\endhead
Scalar & Scalar & Scalar & c := a +/- b\\ \hline
Scalar & Array{[}n, m, \ldots{}{]} & Array{[}n, m, \ldots{}{]} & c{[}j,
Expand All @@ -962,7 +962,7 @@ \subsection{Array Element-wise Addition, Subtraction, and String Concatenation}\
\begin{longtable}[]{|l|l|l|}
\caption{Unary operators. The element-wise (.+, .-) and normal (+, -) operators give the same results.}\\
\hline
\emph{Type of a} & \emph{Result of} \lstinline!+/-! \emph{a} & \emph{Operation c :=
\tablehead{Type of a} & \tablehead{Result of} \lstinline!+/-! \tablehead{a} & \tablehead{Operation c :=
+/- a (j=1:n, k=1:m)}\\ \hline
\endhead
Scalar & Scalar & c := +/- a\\ \hline
Expand All @@ -978,8 +978,8 @@ \subsection{Array Element-wise Multiplication}\doublelabel{array-element-wise-mu
\begin{longtable}[]{|l|l|l|l|}
\caption{Scalar and scalar to array multiplication of numeric elements}\\
\hline
\emph{Type of s} & \emph{Type of a} & \emph{Type of s* a and a*s} &
\emph{Operation} c := s*a or c := a*s (j=1:n, k=1:m)\\ \hline
\tablehead{Type of s} & \tablehead{Type of a} & \tablehead{Type of s* a and a*s} &
\tablehead{Operation} c := s*a or c := a*s (j=1:n, k=1:m)\\ \hline
\endhead
Scalar & Scalar & Scalar & c := s * a\\ \hline
Scalar & Vector {[}n{]} & Vector {[}n{]} & c{[}j{]} := s*
Expand All @@ -998,8 +998,8 @@ \subsection{Array Element-wise Multiplication}\doublelabel{array-element-wise-mu
\begin{longtable}[]{|l|l|l|l|}
\caption{Array element-wise multiplication}\\
\hline
\emph{Type of a} & \emph{Type of b} & \emph{Type of a .* b} &
\emph{Operation} c:=a .* b (j=1:n, k=1:m)\\ \hline
\tablehead{Type of a} & \tablehead{Type of b} & \tablehead{Type of a .* b} &
\tablehead{Operation} c:=a .* b (j=1:n, k=1:m)\\ \hline
\endhead
Scalar & Scalar & Scalar & c := a * b\\ \hline
Scalar & Array{[}n, m, \ldots{}{]} & Array{[}n, m, \ldots{}{]} & c{[}j,
Expand All @@ -1018,8 +1018,8 @@ \subsection{Matrix and Vector Multiplication of Numeric Arrays}\doublelabel{matr
\begin{longtable}[]{|l|l|l|l|}
\caption{Matrix and vector multiplication of arrays with numeric elements.}\\
\hline
\emph{Type of a} & \emph{Type of b} & \emph{Type of a* b} &
\emph{Operation c := a*b}\\ \hline
\tablehead{Type of a} & \tablehead{Type of b} & \tablehead{Type of a* b} &
\tablehead{Operation c := a*b}\\ \hline
\endhead
Vector {[}n{]} & Vector {[}n{]} & Scalar & c :=
$\textrm{sum}_k$(a{[}k{]}*b{[}k{]}), k=1:n\\ \hline
Expand Down Expand Up @@ -1054,8 +1054,8 @@ \subsection{Division of Scalars or Numeric Arrays by Numeric Scalars}\doublelabe
\begin{longtable}[]{|l|l|l|l|}
\caption{Division of scalars and arrays by numeric elements.}\\
\hline \endhead
\emph{Type of a} & \emph{Type of s} & \emph{Result of a / s} &
\emph{Operation c := a / s (j=1:n, k=1:m)}\\ \hline
\tablehead{Type of a} & \tablehead{Type of s} & \tablehead{Result of a / s} &
\tablehead{Operation c := a / s (j=1:n, k=1:m)}\\ \hline
Scalar & Scalar & Scalar & c := a / s\\ \hline
Vector{[}n{]} & Scalar & Vector{[}n{]} & c{[}k{]} := a{[}k{]} /
s\\ \hline
Expand All @@ -1077,8 +1077,8 @@ \subsection{Array Element-wise Division}\doublelabel{array-element-wise-division
\begin{longtable}[]{|l|l|l|l|}
\caption{Element-wise division of arrays}\\
\hline \endhead
\emph{Type of a} & \emph{Type of b} & \emph{Type of a ./ b} &
\emph{Operation} c:=a ./ b (j=1:n, k=1:m)\\ \hline
\tablehead{Type of a} & \tablehead{Type of b} & \tablehead{Type of a ./ b} &
\tablehead{Operation} c:=a ./ b (j=1:n, k=1:m)\\ \hline
Scalar & Scalar & Scalar & c := a / b\\ \hline
Scalar & Array{[}n, m, \ldots{}{]} & Array{[}n, m, \ldots{}{]} & c{[}j,
k, \ldots{}{]} := a / b{[}j, k, \ldots{}{]}\\ \hline
Expand Down Expand Up @@ -1117,8 +1117,8 @@ \subsection{Exponentiation of Scalars of Numeric Elements}\doublelabel{exponenti
\begin{longtable}[]{|l|l|l|l|}
\caption{Element-wise exponentiation of arrays}\\
\hline
\emph{Type of a} & \emph{Type of b} & \emph{Type of a .\^{} b} &
\emph{Operation} c:=a .\^{} b (j=1:n, k=1:m)\\ \hline
\tablehead{Type of a} & \tablehead{Type of b} & \tablehead{Type of a .\^{} b} &
\tablehead{Operation} c:=a .\^{} b (j=1:n, k=1:m)\\ \hline
\endhead
Scalar & Scalar & Scalar & c := a \^{} b\\ \hline
Scalar & Array{[}n, m, \ldots{}{]} & Array{[}n, m, \ldots{}{]} & c{[}j,
Expand Down
59 changes: 29 additions & 30 deletions chapters/functions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1804,8 +1804,8 @@ \subsubsection{Simple Types}\doublelabel{simple-types}
Arguments of \emph{simple} types are by default mapped as follows for C:
\begin{longtable}[]{|l|l|l|}
\hline
\emph{Modelica} & \multicolumn{2}{c|}{\emph{C}}\\
& \emph{Input} & \emph{Output}\\ \hline
\tablehead{Modelica} & \multicolumn{2}{c|}{\tablehead{C}}\\
& \tablehead{Input} & \tablehead{Output}\\ \hline
\endhead
\lstinline!Real! & \lstinline!double! & \lstinline!double *!\\ \hline
\lstinline!Integer! & \lstinline!int! & \lstinline!int *!\\ \hline
Expand All @@ -1832,8 +1832,8 @@ \subsubsection{Simple Types}\doublelabel{simple-types}
Arguments of simple types are by default mapped as follows for FORTRAN~77:
\begin{longtable}[]{|l|l|l|}
\hline
\emph{Modelica} & \multicolumn{2}{c|}{FORTRAN 77}\\
& \emph{Input} & \emph{Output}\\ \hline
\tablehead{Modelica} & \multicolumn{2}{c|}{FORTRAN~77}\\
& \tablehead{Input} & \tablehead{Output}\\ \hline
\endhead
\lstinline!Real! & \lstinline!DOUBLE PRECISION! & \lstinline!DOUBLE PRECISION!\\ \hline
\lstinline!Integer! & \lstinline!INTEGER! & \lstinline!INTEGER!\\ \hline
Expand Down Expand Up @@ -1882,48 +1882,47 @@ \subsubsection{Arrays}\doublelabel{arrays-1}

\begin{longtable}[]{|l|l|}
\hline
\emph{Modelica} & C\\ \hline
& \emph{Input and Output}\\ \hline
\tablehead{Modelica} & \tablehead{C}\\ \hline
& \tablehead{Input and Output}\\ \hline
\endhead
\emph{T}{[}$\textit{dim}_1${]} & \emph{T'} *, size\_t
$\textit{dim}_1$\\ \hline
\emph{T}{[}$\textit{dim}_1$,$\textit{dim}_2${]} &
\emph{T'} *, size\_t $\textit{dim}_1$, size\_t
$\textit{dim}_2$\\ \hline
\emph{T}{[}$\textit{dim}_1$, \ldots{},
$\textit{dim}_{n}${]} & \emph{T'} *, size\_t
$\textit{dim}_1$, \ldots{}, size\_t
$\textit{dim}_{n}$\\ \hline
\lstinline[mathescape=true]!T[$\textit{dim}_{1}$]! &
\lstinline[mathescape=true,language=C]!T' *, size_t $\textit{dim}_{1}$!
\\ \hline
\lstinline[mathescape=true]!T[$\textit{dim}_{1}$, $\textit{dim}_{2}$]! &
\lstinline[mathescape=true,language=C]!T' *, size_t $\textit{dim}_{1}$, size_t$\textit{dim}_{2}$!
\\ \hline
\lstinline[mathescape=true]!T[$\textit{dim}_{1}$, $\ldots$, $\textit{dim}_{n}$]! &
\lstinline[mathescape=true,language=C]!T' *, size_t $\textit{dim}_{1}$, $\ldots$, size_t $\textit{dim}_{n}$!
\\ \hline
\end{longtable}

The method used to pass array arguments to FORTRAN 77 functions in the
The method used to pass array arguments to FORTRAN~77 functions in the
absence of an explicit external function call is similar to the one
defined above for C: first the address of the array, then the dimension
sizes as integers. See the table below. The type T is allowed to be any
of the simple types which can be passed to FORTRAN 77 as defined in
of the simple types which can be passed to FORTRAN~77 as defined in
\autoref{simple-types} and it is mapped to the type T' as defined in that
section.

\begin{longtable}[]{|l|l|}
\hline
\emph{Modelica} & \emph{FORTRAN 77}\\ \hline
& \emph{Input and Output}\\ \hline
\tablehead{Modelica} & \tablehead{FORTRAN~77}\\ \hline
& \tablehead{Input and Output}\\ \hline
\endhead
\emph{T}{[}$\textit{dim}_1${]} & \emph{T'}, INTEGER
$\textit{dim}_1$\\ \hline
\emph{T}{[}$\textit{dim}_1$,$\textit{dim}_2${]} &
\emph{T'}, INTEGER $\textit{dim}_1$, INTEGER
$\textit{dim}_2$\\ \hline
\emph{T}{[}$\textit{dim}_1$, \ldots{},
$\textit{dim}_{n}${]} & \emph{T'}, INTEGER
$\textit{dim}_1$, \ldots{}, INTEGER
$\textit{dim}_{n}$\\ \hline

\lstinline[mathescape=true]!T[$\textit{dim}_{1}$]! &
\lstinline[mathescape=true,language=FORTRAN77]!T', INTEGER $\textit{dim}_{1}$!
\\ \hline
\lstinline[mathescape=true]!T[$\textit{dim}_{1}$, $\textit{dim}_{2}$]! &
\lstinline[mathescape=true,language=FORTRAN77]!T', INTEGER $\textit{dim}_{1}$, INTEGER $\textit{dim}_{2}$!
\\ \hline
\lstinline[mathescape=true]!T[$\textit{dim}_{1}$, $\ldots$, $\textit{dim}_{n}$]! &
\lstinline[mathescape=true,language=FORTRAN77]!T', INTEGER $\textit{dim}_{1}$, $\ldots$, INTEGER $\textit{dim}_{n}$!
\\ \hline
\end{longtable}

\begin{example}
The following two examples illustrate the default mapping of
array arguments to external C and FORTRAN 77 functions.
array arguments to external C and FORTRAN~77 functions.

\begin{lstlisting}[language=modelica]
function foo
Expand Down
2 changes: 1 addition & 1 deletion chapters/inheritance.tex
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ \subsection{Merging of Modifications}\doublelabel{merging-of-modifications}
A flattening of class \lstinline!C4! will give an object with the following variables:
\begin{longtable}[]{|@{}l|l@{}|}
\hline \endhead
\emph{Variable} & \emph{Default value}\\ \hline
\tablehead{Variable} & \tablehead{Default value}\\ \hline
\lstinline!x1! & \lstinline!none!\\ \hline
\lstinline!x2! & \lstinline!22!\\ \hline
\lstinline!x3.a! & \lstinline!33!\\ \hline
Expand Down
2 changes: 1 addition & 1 deletion chapters/introduction.tex
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ \section{Some Definitions}\doublelabel{some-definitions}
in the glossary in \autoref{glossary}. Some important terms are:
\begin{tabular}{|l|p{10cm}|}
\hline
\emph{Term} & \emph{Definition} \\
\tablehead{Term} & \tablehead{Definition} \\
\hline
Component & An element defined by the production
\lstinline!component-clause! in the Modelica grammar (basically a
Expand Down
2 changes: 1 addition & 1 deletion chapters/operatorsandexpressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ \section{Operator Precedence and Associativity}\doublelabel{operator-precedence-
\caption{Operators}
\begin{tabular}{|p{5cm}|p{5cm}|p{4cm}|}
\hline
\emph{Operator Group} & \emph{Operator Syntax} & \emph{Examples}\\ \hline
\tablehead{Operator Group} & \tablehead{Operator Syntax} & \tablehead{Examples}\\ \hline
postfix array index operator & \lstinline![]! & \lstinline!arr[index]! \\ \hline
postfix access operator & \lstinline!.! & \lstinline!a.b! \\ \hline
postfix function call & \lstinline[mathescape=true]!$\mathit{funcName}$($\mathit{functionArguments}$)! & \lstinline!sin(4.36)! \\ \hline
Expand Down
3 changes: 3 additions & 0 deletions preamble.tex
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
% characters to also produce an \allowbreak{} following the directory separator.
\newcommand{\filename}[1]{\mbox{\textsf{#1}}}

% Formatting of table headings.
\newcommand{\tablehead}[1]{\textit{#1}}

\setcounter{secnumdepth}{5}
% Note: Toc changed for appendex
\setcounter{tocdepth}{1}
Expand Down

0 comments on commit 097846b

Please sign in to comment.