Graphics, Figures & Tables2 table questions: align caption & notes environment

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
PGScooter
Posts: 31
Joined: Mon Jul 14, 2008 2:47 pm

2 table questions: align caption & notes environment

Post by PGScooter »

Hi,

I cannot figure out how to align the caption of a table. My caption is at the top and I am using tabularx package. I would like to align it to the left.

Also, what is the best way to put notes in a table? Is there an environment or package that is recommended to use?

thank you

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

2 table questions: align caption & notes environment

Post by localghost »

PGScooter wrote:[...] I cannot figure out how to align the caption of a table. My caption is at the top and I am using tabularx package. I would like to align it to the left. [...]
That's definitely a job for the caption package.
PGScooter wrote:[...] Also, what is the best way to put notes in a table? Is there an environment or package that is recommended to use? [...]
Try the threeparttable package. Since the package has no manual, you have to look at the *.sty file itself to get a short description of the provided commands and environments.


Best regards
Thorsten¹
corderin
Posts: 77
Joined: Sun Dec 14, 2008 2:27 pm

2 table questions: align caption & notes environment

Post by corderin »

Hi,

if with notes you are thinking on table footnotes, my proposal is the minipage environment, it works fine. Try with:

Code: Select all

\begin{table}[!ht]
\begin{minipage}{\textwidth}
\captionof{table}[TOC title]{\label{tab:my_table}My table with footnotes.}
\begin{center}
\resizebox{0.9\textwidth}{!} {
\begin{tabular}{|c|c|} 
\hline
A\footnote[1]{Uppercase a.}   &  B\\
\hline
C   &  D\footnote[2]{Another footnote.}\\
\hline
\end{tabular}
}
\end{center}
\end{minipage}
\end{table}
Add these two packages

Code: Select all

\usepackage{caption}
\usepackage{mpfnmark}
\renewcommand*{\thempfootnote}{\fnsymbol{mpfootnote}}
The second package let you define the symbols you are using in the footnotes using renewcommand like it is shown...

localghost wrote:That's definitely a job for the caption package.
The boxhandler package may also work...
corderin
Posts: 77
Joined: Sun Dec 14, 2008 2:27 pm

2 table questions: align caption & notes environment

Post by corderin »

I have found a new solution the sidecap package!!!

I hope this is what you are looking for!
PGScooter
Posts: 31
Joined: Mon Jul 14, 2008 2:47 pm

Re: 2 table questions: align caption & notes environment

Post by PGScooter »

great! thank you for the replies. It's nice to have a few different approaches to a problem.

thanks!
nanomir
Posts: 7
Joined: Fri Jan 09, 2009 6:39 pm

2 table questions: align caption & notes environment

Post by nanomir »

Hi,

I just need to also like to left-align a caption to a figure, and saw this:
localghost wrote:
PGScooter wrote:[...] I cannot figure out how to align the caption of a table. My caption is at the top and I am using tabularx package. I would like to align it to the left. [...]
That's definitely a job for the caption package.
So, I took a look at http://tug.ctan.org/tex-archive/macros/ ... on-eng.pdf, and the word "align" is mentioned only three times in it, here:
The command
\sidecaptionvpos{hfloat typei}{hposi}
sets the vertical position of the side-caption. hposi can be either ‘t’ (for top alignment), ‘b’ (for
bottom alignment), or ‘c’ (for center alignment).
That is - no mention of left alignment ... Just to make myself clear, what I'd like to do, is move the caption to where the arrows indicate:
Image

Any suggestions on what could be used to achieve this?

Thanks....
Attachments
leftaligncaption.jpg
leftaligncaption.jpg (67.78 KiB) Viewed 27035 times
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

2 table questions: align caption & notes environment

Post by localghost »

Just give the option singlelinecheck=false to the caption package as described in the manual (Section 2.2 - Justification, p. 8f).


Best regards
Thorsten¹
nanomir
Posts: 7
Joined: Fri Jan 09, 2009 6:39 pm

2 table questions: align caption & notes environment

Post by nanomir »

Localghost,
localghost wrote:Just give the option singlelinecheck=false to the caption package as described in the manual (Section 2.2 - Justification, p. 8f).
Thanks for the great advice - indeed, that is it.. Unfortunately the 'align' terminology sticks too much for me, so I missed the singlelinecheck :) Finally this is what worked for me (intended to show a figure inside a minipage, which cannot be done with figure):

Code: Select all

\begin{raggedright}
\includegraphics[width=4.3957in,height=0.3957in]{myimage.jpg}
\captionsetup{singlelinecheck=off,justification=raggedright}
\captionof{figure}{\textit{Picture zero}}
\label{fig:piczero}
\end{raggedright}


Thanks again !!! :D
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

2 table questions: align caption & notes environment

Post by localghost »

This seems a little bit too complicated to me. I worked out another short example.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[font=small,labelfont=bf,singlelinecheck=false]{caption}
\usepackage{lmodern}
\usepackage{blindtext}

\parindent0em

\begin{document}
  \blindtext

  \begin{figure}[!ht]
    \centering
    \begin{minipage}{0.5\textwidth}      % Desired width of the figure
      \rule{\linewidth}{0.5\linewidth}   % To be replaced with graphics file
      \caption{Dummy Figure}\label{fig:dummy}
    \end{minipage}
  \end{figure}

  \blindtext
\end{document}
The graphics file inside should have the same width as the minipage environment. This can easily be done by specifying its width as the current line width.

Code: Select all

\includegraphics[width=\linewidth]{graphicsfile}
This way you get a centred figure with a left aligned caption.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

2 table questions: align caption & notes environment

Post by gmedina »

I'd like to suggest another simpler approach using the floatrow package:

Code: Select all

\documentclass{article}
\usepackage[font=small,labelfont=bf,singlelinecheck=false]{caption}
\usepackage{floatrow}

\begin{document}

\begin{figure}
\ffigbox[\FBwidth]
  {\caption{Dummy figure}\label{fig:test}}
  {\rule{7cm}{4cm}}%just to simulate an actual figure
\end{figure}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply