Skip to content

Commit

Permalink
Explain use of quotes around code fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Dec 18, 2022
1 parent 879245b commit 3356f85
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions chapters/introduction.tex
Expand Up @@ -130,6 +130,9 @@ \section{Notation}\label{notation}
It is common to mix Modelica code with mathematical notation.
For example, \lstinline!average($x$, $y$)! could be defined as $\frac{x + y}{2}$.

Inline code fragments are sometimes surrounded by quotes to clearly mark their beginning and end, or to emphasize separation from the surrounding text.
For example, `\lstinline!,!' is used to separate the arguments of a function call.

\begin{definition}[Something]% Do not add this one to the index!
Text defining the meaning of \emph{something}.
\end{definition}
Expand Down
16 changes: 16 additions & 0 deletions styleguide.md
Expand Up @@ -189,6 +189,22 @@ Fixed ordinals: 1st, 2nd, 3rd.
Symbolic ordinals: $n$th, $(n+1)$th.
```

## Inline code

Inline code is typically formatted using just the `\lstinline` macro.

Since the change of type face can be very hard to notice for small code fragments, quotes may sometimes be used to emphasize the distinction from the surrounding text, unless the code fragment consists of a single identifier (consistent presentation of identifiers is given higher priority than clarity of presentation in this case).
Use single quotes for a single letter code fragment, for example:
```
When automatically deriving a name, any trailing `\lstinline!1!' in the …
```
Use double quotes for a multi-letter code fragment, for example:
```
… and prepending the reduction expression with ``\lstinline!functionName(!''.
```

Avoid overusing quotes around code fragments, especially for multi-letter fragments.

## Code listings

### Modelica listings
Expand Down

0 comments on commit 3356f85

Please sign in to comment.