Writing functions and LaTeX

How do I write a function in LaTeX? I tried writing f(...), but it just appears as a normal f. Do I have to add a math package or is it already in LaTeX

• Hmmm... could you elaborate? That is, could you provide a visual of what you're actually after? – Werner Jan 18 '16 at 4:35
• Do you mean that you want to write down a mathematical function, rather than defining and using a function in LaTeX? – Karlo Jan 18 '16 at 11:47

Anything that is maths should go in math mode. There are a number of ways of entering math mode, and actually different types. The simplest is

• $...$

Thus, you will write $f(...)$

This is for in-line maths, maths that should go in the text, e.g.:

The function $f(x) = x^{2}$ is an interesting function, because ...

You may also use:

• $$...$$

Which does exactly the same thing:

The function $$f(x) = x^{2}$$ is an interesting function, because ...

For displayed equations, you should use:

• $...$

This will display your equation. By default it will be on a new line, centred, and there will be a small skip between the lines of text preceding and succeeding the equation. In addition, certain symbols - such as the summation and integral signs - will be set larger by default. Fractions will also be larger by default and limits, etc. will, by default, be placed above and below (except with integrals). This is suited to large displayed equations. In inline math mode we have smaller symbols, limits are set like sub- and superscripts and fractions appear smaller. This is so that the mathematics is integrated smoothly into the text and does not cause ugly line heights and excessive white space.

So you could have:

And from this it follows that
$f(x) = x^{2}$

There are also a number of environments, such as equation and flalign* which are maths environments and put you, by default, into math mode, e.g.:

The equation we shall begin with is:
\begin{equation}
f(x) = x^{2}
\end{equation}

These environments usually display your equations.

P.S.: You should definitely load the amsmath package at the least.

• P.P.S.: flalign even requires amsmath (which you know, of course, but it might not be clear from the text.) – Torbjørn T. Jan 18 '16 at 7:53

If we use \begin{equation} \end{equation}, our equation has a number above it. But if you don't want have it, it is sufficient you write * after equation as follows:

\begin{equation*}
\end{equation*}