Graphics, Figures & TablesLeft-alignment of caption in table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
kriss
Posts: 3
Joined: Fri Jul 27, 2012 5:15 pm

Left-alignment of caption in table

Post by kriss »

Hi,

I use a combination of the table and tabularx environment so that I can control the width of the table at will. However, I am unable to justify the caption (declared in the table environment) to the left side of the actual table that's declared using the tabularx environment. Any suggestions how to achieve such a justification?

Thanks,

~K

Code: Select all

\usepackage[font=bf,justification=raggedright,singlelinecheck=true,tableposition=top]{caption}
\usepackage{amsmath,amssymb,float, geometry,graphicx,natbib, tabularx,bm,pdflscape}

\begin{document}

\begin{table}[h]
\caption{Caption}
\centering
\begin{tabular*}{0.3\textwidth}{ llll }
\hline 
\label{table_silverscreen}
 & Col 1 & Col 2\\
\hline
Line 1 & 18.1\% & 85.9\%\\
Line 1 & 18.1\% & 85.9\%\\
\hline
\multicolumn{4}{l}{\footnotesize Sources:}
\end{tabular*}
\end{table}

\end{document}
Last edited by cgnieder on Thu Aug 30, 2012 5:39 pm, edited 1 time in total.

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Left-alignment of caption in table

Post by sommerfee »

Since you are using the caption package this would be a potential solution:

Code: Select all

\documentclass{article}

\usepackage[font=bf,justification=raggedright,singlelinecheck=true,tableposition=top]{caption}
\usepackage{amsmath,amssymb,float, geometry,graphicx,natbib, tabularx,bm,pdflscape}

\captionsetup[table]{slc=off}

\begin{document}

\begin{table}[h]
\centering
\captionbox{Caption}{%
\begin{tabular*}{0.3\textwidth}{ llll }
\hline 
\label{table_silverscreen}
 & Col 1 & Col 2\\
\hline
Line 1 & 18.1\% & 85.9\%\\
Line 1 & 18.1\% & 85.9\%\\
\hline
\multicolumn{4}{l}{\footnotesize Sources:}
\end{tabular*}}
\end{table}

\end{document}
Please note that this needs v3.2 or newer of the caption package.

As an alternative one could use the threeparttable, the ctable, or the floatrow package to archive the requested layout.
Last edited by cgnieder on Thu Aug 30, 2012 10:11 pm, edited 1 time in total.
Post Reply