1

i'm using the {fei} class im my document and my preamble is pretty simple as follows

\documentclass[rascunho]{fei}
\usepackage[utf8]{inputenc}
\usepackage{gensymb}
\usepackage{cancel}

when using the \ref{} command to call an equation as in the example below, the resut is pretty much the expected:

\begin{equation}
\nu_{max} \propto T \Leftrightarrow \nu_{max}=Constante_{2}.T
\label{eq4}
\end{equation}
onde, para um corpo negro, a equação (\ref{eq3})

Result from the code above

But when using the exact same command to call in a figure i get an error, the code go as following:

\begin{figure}[h!]
\center
\includegraphics[scale=0.9]{fig15.jpg}
\label{fig15}
\end{figure}

And thats the result when i  use for figures

Any equation that i reference works perfectly fine, but every single figure i try use the same method shows this error, i read that compiling 2 or more times might be able to fix the issue, but i tried several times and it persists.

i'm pretty sure it must be something really simple and easy to fix, but cant find what no matter how much i try....

  • 1
    You need to reference a caption. A figure environment without \caption doesn't generate a number LaTeX can refer to. By the way you should use \centering rather than \center. – egreg Dec 24 '17 at 20:33
  • 1
    Also you should load siunitx and input the value of the constant as \SI{2,898e-3}{\meter\kelvin} – egreg Dec 24 '17 at 20:36
  • Ohh my, i have no ideia how i didn't realize it sooner, i knew it was something simple right under my nose. Thank you very much for your help @egreg, and sorry to take your time with such a silly question i'm really grateful – Lucas Salgueiro Dec 24 '17 at 20:38
  • Also you should load siunitx and input the value of the constant as \SI{2,898e-3}{\meter\kelvin} <br/> i didn't even know that was even a thing, going to try right away – Lucas Salgueiro Dec 24 '17 at 20:40
  • It looks so much better now, i can't thank you enough, my thessi will look much prettier with your tips – Lucas Salgueiro Dec 24 '17 at 20:47
3

You can use \label after LaTeX has generated a number; a figure environment, by itself, doesn't generate a number: it's \caption that does.

\documentclass[rascunho]{fei}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{graphicx}

\sisetup{output-decimal-marker={,}}

\begin{document}

\begin{equation}
\nu_{\mathrm{max}} \propto T \Leftrightarrow \nu_{\mathrm{max}}=
\mathrm{Constante}_{2}\cdot T
\label{eq:nu-max}
\end{equation}
onde, para um corpo negro, a equação~(\ref{eq:nu-max})
vale \SI{2,898e-3}{\meter\kelvin}.

\begin{figure}[htp]
\centering

\includegraphics[width=3cm]{example-image}

\caption{Esta é uma legenda}
\label{fig:example}

\end{figure}

O gráfico (A) de figura~\ref{fig:example} mostra a distribuição de Boltzmann.

\end{document}

Now the reference can work.

enter image description here

Some other points. The (low) period is never used to denote multiplication. Textual inserts in a math formula should be upright. For the constant and in other similar instances, it's best to use siunitx that guarantees uniform appearance across the document (for instance, the symbol for kelvin is an uppercase K). If you prefer to have explicit multiplication symbols between units, change the \sisetup command in the preamble into

\sisetup{
  output-decimal-marker={,},
  inter-unit-product=\ensuremath{{}\cdot{}},
}

and the output would become

enter image description here

with no change in the document code.

Use a tie between the word “equação” as well as “figura” and the reference number.

It's incorrect to use \center; rather use \centering or nothing at all, as the class sets left aligned captions, so probably left aligned images are better suited.

  • Utterly perfect, thank you sensei. Sorry for the huge ammount of mistakes, i began using latex just a few days ago – Lucas Salgueiro Dec 24 '17 at 20:56
  • @LucasSalgueiro Don't worry: being a novice you're supposed not to know how to use the program. ;-) Glad to be helpful. – egreg Dec 24 '17 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.