LaTeX forum ⇒ Graphics, Figures & TablesHow to centering a table and set the caption under the Table

Information and discussion about graphics, figures & tables in LaTeX documents.
ohmp2007
Posts: 7
Joined: Fri Aug 01, 2014 3:07 pm

How to centering a table and set the caption under the Table

Postby ohmp2007 » Wed Aug 27, 2014 3:13 pm

Hi!

I need help to find a solution for me problem that i have with the table! I try to find a way to center me table and also to set the caption of me table under me table.

I tried with \centering and also \center but nothing will work. I read that if I use \centering I need a paragraph to work :?: :?:

  1. \begin{table}[H]
  2. \centering
  3. \begin{tabular}{|c | c| }
  4.  
  5. \textbf{Wichtig} & \textbf{Wichtiger} \\ \hline
  6.  
  7. Prozesse und Tools & Individuen und Interaktion \\ \hline
  8. detaillierte Dokumentation & funktionierende Software \\ \hline
  9. Vertragsverhandlungen & Zusammenarbeit mit dem Kunden \\ \hline
  10. einem Plan folgen & sich Änderungen anpassen \\ \hline
  11.  
  12. \caption{Die Gewichtung des agilen Manifests}
  13. \label{agiles manifest}
  14.  
  15. \end{tabular}
  16. \end{table}

Tags:

mas
Posts: 219
Joined: Thu Dec 04, 2008 4:39 am

Postby mas » Thu Aug 28, 2014 4:07 am

You have to move the caption outside of the tabular environment. The following code does what you want:
  1. \documentclass{article}
  2. \usepackage{showframe}
  3. \begin{document}
  4.  
  5. \begin{table}[H]
  6. \centering
  7. \begin{tabular}{|c | c| }
  8. \hline
  9. \textbf{Wichtig} & \textbf{Wichtiger} \\ \hline
  10. Prozesse und Tools & Individuen und Interaktion \\ \hline
  11. detaillierte Dokumentation & funktionierende Software \\ \hline
  12. Vertragsverhandlungen & Zusammenarbeit mit dem Kunden \\ \hline
  13. einem Plan folgen & sich Änderungen anpassen \\ \hline
  14. \end{tabular}
  15.  
  16. \caption{Die Gewichtung des agilen Manifests}
  17. \label{agiles manifest}
  18.  
  19. \end{table}
  20.  
  21. \end{document}

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim

User avatar
cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Thu Aug 28, 2014 9:16 am

ohmp2007 wrote:Hi!

I need help to find a solution for me problem that i have with the table! I try to find a way to center me table and also to set the caption of me table under me table.

I tried with \centering and also \center but nothing will work. I read that if I use \centering I need a paragraph to work :?: :?:


Like mas said. This is easy to understand if you think of the whole {tabular} as one letter, say T. Then the structure of the floating environment {table} becomes a lot clearer:

  1. \begin{table}
  2. \centering
  3. T
  4. \caption{my caption}
  5. \label{tab:my-table}
  6. \end{table}


Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

ohmp2007
Posts: 7
Joined: Fri Aug 01, 2014 3:07 pm

Postby ohmp2007 » Thu Aug 28, 2014 2:50 pm

@mas

If I cpy&paste your solution. I get an error message: Can be used only in preamble. :?:

thx

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

Postby Johannes_B » Thu Aug 28, 2014 5:11 pm

mas posted a complete compilable minimal example, as all helpers do most of the time. You have to delete the obvious parts before copying it to your document.
The complete error message would also be very helpful.

btw: If you are looking for german help, check out our partner site TeXwelt.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

ohmp2007
Posts: 7
Joined: Fri Aug 01, 2014 3:07 pm

Postby ohmp2007 » Mon Sep 01, 2014 10:52 am

Hi!

i tried it with these code:

  1. \begin{table}[H]
  2. \centering
  3. \begin{tabular}{|c | c| }
  4. \hline
  5. \textbf{Wichtig} & \textbf{Wichtiger} \\ \hline
  6. Prozesse und Tools & Individuen und Interaktion \\ \hline
  7. detaillierte Dokumentation & funktionierende Software \\ \hline
  8. Vertragsverhandlungen & Zusammenarbeit mit dem Kunden \\ \hline
  9. einem Plan folgen & sich Änderungen anpassen \\ \hline
  10. \end{tabular}
  11.  
  12. \caption{Die Gewichtung des agilen Manifests}
  13. \label{agiles manifest}
  14.  
  15. \end{table}


The result is the same the table begins from the left side. And the caption is not under the table it is at the top of the table. :|

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

Postby Johannes_B » Mon Sep 01, 2014 11:51 am

All you are giving us is a snippet of code, which is pretty useless. Try to prepare a minimal working example to find the cause of the behaviour. You might have loaded package floatrow or something, i am not psychic.

Go back to the example provided by mas and click on »Open in Writelatex« to see, that the table is 1) centered and 2) the caption is below the table.

Additional hint: Tables usually have their caption on top. Have a look at package booktabs.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

ohmp2007
Posts: 7
Joined: Fri Aug 01, 2014 3:07 pm

Postby ohmp2007 » Mon Sep 01, 2014 2:25 pm

Ok!

Here is me code.

usepackages
  1. \usepackage[utf8x]{inputenc}
  2. \usepackage[scaled]{helvet}
  3. \renewcommand*\familydefault{\sfdefault}
  4. \usepackage[T1]{fontenc}
  5. \usepackage[T1]{fontenc}
  6. \usepackage[ngerman]{babel}
  7.  
  8. \usepackage{textcomp}
  9. \usepackage{graphicx}
  10. \usepackage{caption}[2008/08/24]
  11.  
  12. \usepackage{scrhack}
  13. \usepackage{listings}
  14. \usepackage{setspace}
  15. \usepackage{geometry}
  16.  
  17. \usepackage{color}
  18.  
  19. \usepackage{subfig}
  20. \usepackage{array}
  21. \usepackage{multirow}
  22. \usepackage{color}
  23. \usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
  24. \usepackage{hhline}
  25.  
  26. \usepackage{graphicx}
  27. \usepackage{pdfpages}
  28.  
  29. \usepackage[hyphens]{url}
  30. \usepackage[pdftex]{hyperref}
  31.  
  32. %\usepackage{algorithmicx}
  33.  
  34. \usepackage{caption}
  35. \usepackage{floatrow}
  36. \usepackage{wrapfig}
  37.  
  38. \usepackage{acronym}


format
  1. % listings format
  2. \lstset{frame=single, aboveskip=15pt, framesep=5pt, belowskip=15pt}
  3. \lstset{numbersep=10pt, tabsize=4, numbers=left, numberstyle=\tiny}
  4. \lstset{xleftmargin=15pt, xrightmargin=15pt}
  5.  
  6. \lstset{basicstyle=\normalsize}
  7. \lstset{keywordstyle=\ttfamily\color{OliveGreen}}
  8. \lstset{identifierstyle=\ttfamily\color{CadetBlue}\bfseries}
  9. \lstset{commentstyle=\color{Brown}}
  10. \lstset{stringstyle=\ttfamily, showstringspaces=ture}
  11. \lstset{breaklines=true}
  12.  
  13. \lstset{captionpos=b}
  14. \lstset{language=xml}
  15.  
  16. % setspace format
  17. \onehalfspacing
  18.  
  19. % geometry format
  20. \geometry{a4paper,left=35mm,right=30mm, top=30mm, bottom=30mm}
  21.  
  22. %
  23. \parskip 10pt
  24. \parindent 0mm
  25.  
  26. % hyperref for pdf
  27.  
  28. \hypersetup{
  29. % bookmarks=true, % show bookmarks bar?
  30. % unicode=false, % non-Latin characters in Acrobats bookmarks
  31. pdftoolbar=true, % show Acrobats toolbar?
  32. pdfmenubar=true, % show Acrobats menu?
  33. pdffitwindow=true, % window fit to page when opened
  34. pdfstartview={FitH}, % fits the width of the page to the window
  35. pdftitle={}, % title
  36. pdfauthor={}, % author
  37. pdfsubject={}, % subject of the document
  38. % pdfcreator={Creator}, % creator of the document
  39. pdfproducer={}, % producer of the document
  40. pdfkeywords={}, % list of keywords
  41. pdfnewwindow=true, % links in new window
  42. colorlinks=true, % false: boxed links; true: colored links#
  43. %
  44. % Coloured Links
  45. % linkcolor=blue, citecolor=green, filecolor=magenta, urlcolor=cyan
  46. %
  47. % Black Links
  48. linkcolor=black, citecolor=black, filecolor=black, urlcolor=black
  49. %
  50. %
  51. }
  52.  
  53.  
  54. \floatsetup[table]{capposition=top}
  55. \captionsetup[table]{labelfont=bf,font=small,position=top,labelsep=colon,justification=justified,singlelinecheck=off}
  56.  
  57. \captionsetup[figure]{labelfont=bf,font=small,position=bottom,labelsep=colon,justification=justified,singlelinecheck=off}
  58.  
  59.  
  60. \renewcommand*{\thefigure}{\thechapter-\arabic{figure}}
  61. \renewcommand*{\thetable}{\thechapter-\arabic{table}}
  62.  
  63.  
  64.  

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

Postby Johannes_B » Mon Sep 01, 2014 3:59 pm

Why didn't you follow the link i gave you? Again you are giving us snippets of code leaving your work to be done by us.
  1. \documentclass{article}
  2. \usepackage[utf8x]{inputenc}%I bet you don't need the x
  3. \usepackage[scaled]{helvet}%irrelevent
  4. \renewcommand*\familydefault{\sfdefault}%irrelevent
  5. \usepackage[T1]{fontenc}
  6. \usepackage[T1]{fontenc}
  7. \usepackage[ngerman]{babel}
  8.  
  9. \usepackage{textcomp}%irrelevent
  10. \usepackage{graphicx}%irrelevent
  11. \usepackage{caption}[2008/08/24]
  12.  
  13. \usepackage{scrhack}%irrelevent
  14. \usepackage{listings}%irrelevent
  15. \usepackage{setspace}%irrelevent
  16. \usepackage{geometry}%irrelevent
  17.  
  18. \usepackage{color}%irrelevent
  19.  
  20. \usepackage{subfig}%irrelevent
  21. \usepackage{array}%irrelevent
  22. \usepackage{multirow}%irrelevent
  23. \usepackage{color}%irrelevent
  24. \usepackage[usenames,dvipsnames,svgnames,table]{xcolor}%irrelevent
  25. \usepackage{hhline}%irrelevent
  26.  
  27. \usepackage{graphicx}
  28. \usepackage{pdfpages}
  29.  
  30. \usepackage[hyphens]{url}%irrelevent
  31. \usepackage[pdftex]{hyperref}%irrelevent
  32.  
  33. %\usepackage{algorithmicx}
  34.  
  35. \usepackage{caption}
  36. \usepackage{floatrow}
  37. \usepackage{wrapfig}%irrelevent
  38.  
  39. \usepackage{acronym}%irrelevent
  40.  
  41. % listings
  42. % format
  43. \lstset{frame=single,%irrelevent
  44. aboveskip=15pt,%irrelevent
  45. framesep=5pt,%irrelevent
  46. belowskip=15pt}%irrelevent
  47. \lstset{numbersep=10pt,%irrelevent
  48. tabsize=4,%irrelevent
  49. numbers=left,%irrelevent
  50. numberstyle=\tiny}%irrelevent
  51. \lstset{xleftmargin=15pt,%irrelevent
  52. xrightmargin=15pt}%irrelevent
  53. %irrelevent
  54. \lstset{basicstyle=\normalsize}%irrelevent
  55. \lstset{keywordstyle=\ttfamily\color{OliveGreen}}%irrelevent
  56. \lstset{identifierstyle=\ttfamily\color{CadetBlue}\bfseries}%irrelevent
  57. \lstset{commentstyle=\color{Brown}}%irrelevent
  58. \lstset{stringstyle=\ttfamily,%irrelevent
  59. showstringspaces=ture}%irrelevent
  60. \lstset{breaklines=true}%irrelevent
  61. %irrelevent
  62. \lstset{captionpos=b}%irrelevent
  63. \lstset{language=xml}%irrelevent
  64.  
  65. \onehalfspacing%irrelevent
  66.  
  67. \geometry{a4paper,left=35mm,right=30mm, top=30mm, bottom=30mm}
  68.  
  69. %
  70. \parskip 10pt
  71. \parindent 0mm
  72.  
  73.  
  74. \hypersetup{%irrelevant
  75. % bookmarks=true, % show bookmarks bar?%irrelevant
  76. % unicode=false, % non-Latin characters in Acrobats
  77. % bookmarks%irrelevant
  78. pdftoolbar=true, % show Acrobats toolbar?%irrelevant
  79. pdfmenubar=true, % show Acrobats menu?%irrelevant
  80. pdffitwindow=true, % window fit to page when opened%irrelevant
  81. pdfstartview={FitH}, % fits the width of the page to the window
  82. pdftitle={}, % title
  83. pdfauthor={}, % author
  84. pdfsubject={}, % subject of the document
  85. % pdfcreator={Creator}, % creator of the document
  86. pdfproducer={}, % producer of the document
  87. pdfkeywords={}, % list of keywords
  88. pdfnewwindow=true, % links in new window
  89. colorlinks=true, % false: boxed links; true: colored links#
  90. %
  91. % Coloured Links
  92. % linkcolor=blue, citecolor=green, filecolor=magenta, urlcolor=cyan
  93. %
  94. % Black Links
  95. linkcolor=black, citecolor=black, filecolor=black, urlcolor=black
  96. %
  97. %
  98. }
  99.  
  100.  
  101. \floatsetup[table]{capposition=top}
  102. \captionsetup[table]{labelfont=bf,font=small,position=top,labelsep=colon,justification=justified,singlelinecheck=off}
  103.  
  104. \captionsetup[figure]{labelfont=bf,font=small,position=bottom,labelsep=colon,justification=justified,singlelinecheck=off}
  105.  
  106.  
  107. \renewcommand*{\thefigure}{\thechapter-\arabic{figure}}%irrelevant
  108. \renewcommand*{\thetable}{\thechapter-\arabic{table}}%irrelevant
  109.  
  110. \begin{document}
  111. \begin{table}
  112. \rule{5cm}{4cm}
  113. \caption{your caption}
  114. \end{table}
  115. \end{document}
  116.  

Be careful, you are loading packages twice.

A minimal working example would be the following:
  1. \documentclass{article}
  2. \usepackage[utf8]{inputenc}%I bet you don't need the x
  3. \usepackage[T1]{fontenc}
  4. \usepackage[T1]{fontenc}
  5. \usepackage[ngerman]{babel}
  6.  
  7. \usepackage{caption}
  8. \usepackage{floatrow}
  9.  
  10. %\floatsetup[table]{capposition=top}%puts the caption on top
  11. \captionsetup[table]{labelfont=bf,
  12. font=small,
  13. position=top,
  14. labelsep=colon,
  15. justification=justified,
  16. %singlelinecheck=off%switches of centering
  17. }
  18. \captionsetup[figure]{labelfont=bf,font=small,position=bottom,labelsep=colon,justification=justified,singlelinecheck=off}
  19. \begin{document}
  20. \begin{table}
  21. \centering
  22. \rule{5cm}{4cm}
  23. \caption{your caption}
  24. \end{table}
  25. \end{document}


Seeing this, the reasons are obvious even for the unexperienced. If you don't need package floatrow, just take it out.

I see you are writing in german, you might want to check out our partner site TeXwelt. You can have all your questions answered there, in german.

Additionally, please read Minimale Vorlage vs. Maximale Probleme.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

ohmp2007
Posts: 7
Joined: Fri Aug 01, 2014 3:07 pm

Postby ohmp2007 » Mon Sep 01, 2014 4:58 pm

Yes, I think it is difficult to find the solution. But i can not delete the things that you mark as *irrelevant.

Because I have a document with many pages e.g. I need the \usepackage{acronym} for these chapter.

  1. \chapter*{Abkürzungsverzeichnis}
  2. \addcontentsline{toc}{chapter}{Abkürzungsverzeichniss}
  3.  
  4. \begin{acronym}[SEPSEP] % längste Abkürzung steht in eckigen Klammern
  5. \setlength{\itemsep}{-\parsep} % geringerer Zeilenabstand
  6. \acro{gmbh}[GmbH]{Gesellschaft mit beschränkter Haftung}
  7. \acro{bzw}[bzw.]{beziehungsweise}
  8. \acro{usa}[USA]{Vereinigte Staaten von Amerika}
  9. \acro{engl}[engl.]{englisch}
  10. \acro{it}[IT]{Informationstechnologie}
  11. \acro{u.a.}[u.a.]{und andere}
  12. \end{acronym}


I fixed the problem with the caption.

  1. \floatsetup[table]{capposition=bottom}


The next thing is to bring the table into the center.

And if I try to erase packages it brings me only errors...

Thank you!
Last edited by ohmp2007 on Mon Sep 01, 2014 6:00 pm, edited 1 time in total.


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 7 guests