2

I want to describe C-functions in a document, e.g.:

The function fooBar() does foo and bar...

Should I use a different typeset for the function in the text? I have the feeling that for example \textsc{fooBar()} highlights the function in the text, but for a high cost in appearance.

JaBe
  • 152

1 Answers1

1

You can achieve your goal in different ways. One is to use teletype family fonts \texttt{foobar()} as chrisS has mentioned in the comments. These are fixed-width fonts. Another option, is to use \emph{foobar()} style. Although in normal text '\emph{} seems to be italic, but it is actually more than that. For example, if your text is italic and you use \emph{foobar()} for your function, latex makes it visually distinct by making it normal text. In short, \emph{} guarantees a visual distinction but it is not necessary always pleasing.

enter image description here

Image from The Not So Short Introduction to LaTeX2ε.

My suggestion would be to define a macro of your own such as

\newcommand{\MyCode}[1]{%
\texttt{#1}}

And you it like The function \MyCode{fooBar()} does foo and bar...

This one has the advantage that in case you decide texttt is not what you want, you can change only your macro definition and the effect will apply to your whole document.

For longer pieces of the code, there are packages like listings that can you you with typesetting of different languages (e.g. this Q/A).

Pouya
  • 7,269