## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ How to put the caption for graphics?

Information and discussion about graphics, figures & tables in LaTeX documents.
paulosousa
Posts: 90
Joined: Sun Jun 24, 2012 8:48 pm

### How to put the caption for graphics?

Hello all
Need help!
I have no problem with caption (on top) of tables (have 'Tabela 1', ...) and with caption for the figures (have 'Figura 1', ...), but I need to insert some graphics in the document and I must put a caption on top of it with only 'Gráfico 1', 'Gráfico 2'...

\documentclass[12pt, twoside, a4paper]{article}\usepackage[portuguese]{babel}\usepackage[applemac]{inputenc}\usepackage[left=2.0cm,top=1.5cm,right=2.0cm,bottom=1.75cm]{geometry}\usepackage{amsmath,amssymb,amsfonts,textcomp,setspace,graphicx,color,environ,tabularx,enumitem}\usepackage[font=small,labelfont=bf]{caption} \begin{document} \begin{table}[h]\caption{} \label{table:t2}\centering \small\vspace{-0.20cm}\begin{tabular}{|c|c|c|c|c|c|}\toprule\textbf{Partido} & \hspace{0.35cm} A \hspace{0.35cm} & \hspace{0.25cm} B \hspace{0.25cm} & \hspace{0.25cm} C \hspace{0.25cm}  & \hspace{0.25cm} D \hspace{0.25cm} & \hspace{0.25cm} E \hspace{0.25cm}  \\ \midrule\textbf{Número de votos} & 594  & 418  & 89  &  563 &  71  \\ \bottomrule\end{tabular} \end{table} \begin{figure}[h]\begin{center}\includegraphics[scale=0.450]{figures/3/img1.png}\captionof{figure}{}\label{figure:usf}\end{center}\end{figure}  \end{document}

Should I use something like this?
\addto\captionsportuguese{%\renewcommand{\graphicname}{Gráfico}}

I appreciate any help! Thanks a lot.

Stefan Kottwitz
Posts: 8980
Joined: Mon Mar 10, 2008 9:44 pm
Hi,

use:

\addto\captionsportuguese{\renewcommand{\figurename}{Gráfico}}

And within a figure or table environment use \centering instead of \begin{center} ... \end{center}, such as

\begin{figure}[htbp!]\centering\includegraphics[scale=0.450]{figures/3/img1.png}\caption{Test}\label{figure:usf}\end{figure}

If the caption should go to the top of the graphics, move \caption before \includegraphics. By the way, the more placement options for figures, the easier and the closer the placement, that's why I often use htbp!.

Stefan

paulosousa
Posts: 90
Joined: Sun Jun 24, 2012 8:48 pm
Stefan,

thanks a lot for the suggestion concerning the use of \centering and tomove \caption before \includegraphics
Concerning the suggestion to use \addto\captionsportuguese{\renewcommand{\figurename}{Gráfico}}...
this way I will rename all caption to 'Gráfico n' but in whole doc I need 'Figura 1', 'Figura 2' and 'Gráfico 1'...
How should I do?

Stefan Kottwitz
Posts: 8980
Joined: Mon Mar 10, 2008 9:44 pm
Ah, I understand. Like this:

\usepackage{newfloat}\DeclareFloatingEnvironment[fileext=grf,placement={!htbp},  name=Gráfico,listname={List of Gráficos},]{grafico}...\listofgraficos...\begin{grafico}[htbp!]\centering\includegraphics[scale=0.450]{figures/3/img1.png}\caption{Test}\label{grafico:usf}\end{grafico}

Stefan

Johannes_B
Site Moderator
Posts: 3804
Joined: Thu Nov 01, 2012 4:08 pm
https://tex.stackexchange.com/questions ... cate-float
This is an example for a diagram, you just need to replace the name with what you want.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

paulosousa
Posts: 90
Joined: Sun Jun 24, 2012 8:48 pm
Now it's perfect, thanks a lot Stefan.

Stefan Kottwitz wrote:Ah, I understand. Like this:

\usepackage{newfloat}\DeclareFloatingEnvironment[fileext=grf,placement={!htbp},  name=Gráfico,listname={List of Gráficos},]{grafico}...\listofgraficos...\begin{grafico}[htbp!]\centering\includegraphics[scale=0.450]{figures/3/img1.png}\caption{Test}\label{grafico:usf}\end{grafico}

Stefan