I'm trying to do something tricky with latex -- I need to have a
centered table with a caption which is left justified to the left edge
of the table.
For example, take the following latex code:
---
\documentclass{article}
\begin{document}
This is some sample text
\begin{table}
\caption{Sample Table}
\label{table:sample}
\centering
\begin{tabular}{|l|l|l|}
\hline
\textbf{Name} & \textbf{Account Number} & \textbf{Balance}\\
\hline\hline
Sally & 123 & 24.24\\
Bob & 234 & 45.45\\
Jane & 345 & 56.56\\
\hline
\end{tabular}
\end{table}
\end{document}
---
The caption is centered over the table. I'd like for the caption to
begin right at the upper left edge of the table.
Is there any way to do this (either inline or within the style)?
Thanks for your help in advance!
~Jeff
I'm using the minipage environment to create a centered environment
where the table and caption are both left justified. The only problem
with this is that I have to manually adjust the width of the minipage
width to make the table centered on the page. If there was a way to
dynamically set the width of the minipage environment to the width of
its contents, that would be best, but I can't find any way to do that.
So, this here's the code I'm using right now if you can think of a
better way to do this. I appreciate any help you can give. Thanks!
In my source file:
\begin{table}
\centering
\begin{minipage}{.8\linewidth}
\caption{Ethernet network configuration}
\label{table:ethernet_config}
\begin{tabular}{|l|l|}
\hline
\textbf{Station} & \textbf{IP Address}\\
\hline\hline
blah & blah\\
blah & blah\\
\hline
\end{tabular}
\end{minipage}
\end{table}
In the style file:
\def\@maketablecaption#1#2{
\vskip 10\p@
#1 \\
\\
\textit{#2} \\
Jeff,
Take a look at ctable:
http://www.ctan.org/tex-archive/macros/latex/contrib/ctable/
This is what I use for centered tables with captions that are left
justified.
HTH,
Marc Schwartz