LaTeX forum ⇒ Graphics, Figures & TablesHow 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?

Postby paulosousa » Mon Jan 15, 2018 4:27 pm

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'...

  1. \documentclass[12pt, twoside, a4paper]{article}
  2. \usepackage[portuguese]{babel}
  3. \usepackage[applemac]{inputenc}
  4. \usepackage[left=2.0cm,top=1.5cm,right=2.0cm,bottom=1.75cm]{geometry}
  5. \usepackage{amsmath,amssymb,amsfonts,textcomp,setspace,graphicx,color,environ,tabularx,enumitem}
  6. \usepackage[font=small,labelfont=bf]{caption}
  7.  
  8. \begin{document}
  9.  
  10. \begin{table}[h]
  11. \caption{} \label{table:t2}
  12. \centering
  13. \small
  14. \vspace{-0.20cm}
  15. \begin{tabular}{|c|c|c|c|c|c|}
  16. \toprule
  17. \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} \\
  18. \midrule
  19. \textbf{Número de votos} & 594 & 418 & 89 & 563 & 71 \\
  20. \bottomrule
  21. \end{tabular}
  22. \end{table}
  23.  
  24. \begin{figure}[h]
  25. \begin{center}
  26. \includegraphics[scale=0.450]{figures/3/img1.png}
  27. \captionof{figure}{}
  28. \label{figure:usf}
  29. \end{center}
  30. \end{figure}
  31.  
  32. \end{document}


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


I appreciate any help! Thanks a lot.

User avatar
Stefan Kottwitz
Site Admin
Posts: 8955
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Mon Jan 15, 2018 7:38 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

  1. \begin{figure}[htbp!]
  2. \centering
  3. \includegraphics[scale=0.450]{figures/3/img1.png}
  4. \caption{Test}
  5. \label{figure:usf}
  6. \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
Site admin

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

Postby paulosousa » Tue Jan 16, 2018 7:11 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?

User avatar
Stefan Kottwitz
Site Admin
Posts: 8955
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Tue Jan 16, 2018 7:33 pm

Ah, I understand. Like this:

  1. \usepackage{newfloat}
  2. \DeclareFloatingEnvironment[fileext=grf,placement={!htbp},
  3. name=Gráfico,listname={List of Gráficos},]{grafico}
  4. ...
  5. \listofgraficos
  6. ...
  7. \begin{grafico}[htbp!]
  8. \centering
  9. \includegraphics[scale=0.450]{figures/3/img1.png}
  10. \caption{Test}
  11. \label{grafico:usf}
  12. \end{grafico}


Stefan
Site admin

User avatar
Johannes_B
Site Moderator
Posts: 3795
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Tue Jan 16, 2018 7:34 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

Postby paulosousa » Tue Jan 16, 2018 7:54 pm

Now it's perfect, thanks a lot Stefan.

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

  1. \usepackage{newfloat}
  2. \DeclareFloatingEnvironment[fileext=grf,placement={!htbp},
  3. name=Gráfico,listname={List of Gráficos},]{grafico}
  4. ...
  5. \listofgraficos
  6. ...
  7. \begin{grafico}[htbp!]
  8. \centering
  9. \includegraphics[scale=0.450]{figures/3/img1.png}
  10. \caption{Test}
  11. \label{grafico:usf}
  12. \end{grafico}


Stefan


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 11 guests