Left Align longtable Caption Beginning at Starting Point of Table

I am having trouble left aligning longtable captions in Table 1, starting at the same table object left margin. I am essentially attempting to achieve what I have done in Table 2.

I came across a thread that recommends using LTcapwidth. This works when I manually alter textwidth factors (e.g. \setlength{\LTcapwidth}{.76\textwidth} for Table 1 in MWE), however, I am working on manuscript with a lot of longtables and would want to use a more flexible solution, rather than manually tweak \textwidth for all of them.

Minimum Working Example

\documentclass{article}

\usepackage{multirow}
\usepackage{longtable}
\usepackage{array}
\usepackage{booktabs}
\usepackage{floatrow}

\begin{document}

\section{Table Woes}

%%%\setlength{\LTcapwidth}{.76\textwidth}
\begin{longtable}[c]{
@{}
>{\arraybackslash}p{0.10\linewidth}
>{\arraybackslash}p{0.10\linewidth}
>{\arraybackslash}p{0.10\linewidth}
>{\arraybackslash}p{0.10\linewidth}
>{\arraybackslash}p{0.10\linewidth}
>{\arraybackslash}p{0.10\linewidth}
@{}
}
\caption{Caption needs to be left aligned beginning at same starting position as table}
\label{tab:longtable_captionlable} \\
\toprule
Col 1 & Col 2 & Col 3 & Col 4 & Col 5 & Col 6 \\
\midrule
1 & 2 & 3 & 4 & 5 & 6 \\
1 & 2 & 3 & 4 & 5 & 6 \\
1 & 2 & 3 & 4 & 5 & 6 \\
\bottomrule
\end{longtable}

\begin{table}[h]
\begin{floatrow}
\ttabbox
{\caption{Using floatrow, caption is properly left aligned from the beginning of left table margin.}\label{tab:table_captionlable}}
{\begin{tabular}{|p{0.10\textwidth}|p{0.10\textwidth}|p{0.10\textwidth}|p{0.10\textwidth}|p{0.10\textwidth}|p{0.10\textwidth}|}
\hline
Col 1 & Col 2 & Col 3 & Col 4 & Col 5 & Col 6 \\
\hline
1 & 2 & 3 & 4 & 5 & 6 \\
1 & 2 & 3 & 4 & 5 & 6 \\
1 & 2 & 3 & 4 & 5 & 6 \\
\hline
\end{tabular}}%
\end{floatrow}
\end{table}
\end{document}

• Does is help if you set \floatsetup[longtable]{LTcapwidth=table} in your preamble, after loading floatrow? – Arash Esbati Dec 26 '16 at 18:29
• Precisely what I wanted. Thank you for this. Could you please add this as a solution so we can mark question as having been answered? – lightonphiri Dec 26 '16 at 19:15

Since you're using floatrow, you can use a facility this package provides. From the docs:

7.2 The longtable Package

7.2.1 Additions in The floatrow Package

(...) If you'll write LTcapwidth=table or LTcapwidth=contents, you will get the caption width equal to the width of table.

You can set this key for longtables with \floatsetup[longtable]. Code:

\documentclass{article}

\usepackage{longtable}
\usepackage{array}
\usepackage{booktabs}
\usepackage{floatrow}

\floatsetup[longtable]{LTcapwidth=table}

\begin{document}

\section{Table Works}

\begin{longtable}[c]{@{}*{6}{>{\arraybackslash}p{0.10\linewidth}}@{}}
\caption{Caption needs to be left aligned beginning at same starting
position as table\label{tab:longtable_captionlable}}\\
\toprule
Col 1 & Col 2 & Col 3 & Col 4 & Col 5 & Col 6 \\
\midrule
1 & 2 & 3 & 4 & 5 & 6 \\
1 & 2 & 3 & 4 & 5 & 6 \\
1 & 2 & 3 & 4 & 5 & 6 \\
\bottomrule
\end{longtable}

\begin{table}[h]
\ttabbox{%
\caption{Using floatrow, caption is properly left aligned from the
beginning of left table margin.}\label{tab:table_captionlable}%
}{%
\begin{tabular}{*{6}{|p{0.10\textwidth}}|}
\hline
Col 1 & Col 2 & Col 3 & Col 4 & Col 5 & Col 6 \\
\hline
1 & 2 & 3 & 4 & 5 & 6 \\
1 & 2 & 3 & 4 & 5 & 6 \\
1 & 2 & 3 & 4 & 5 & 6 \\
\hline
\end{tabular}%
}%
\end{table}
\end{document}


Also note that you can use *{num}{cols}-expression in tabular column specification to improve code legibility.

Here is a simple solution:

\documentclass{article}

\usepackage{multirow}
\usepackage{longtable}
\usepackage{array}
\usepackage{booktabs}
\usepackage{floatrow}
\begin{document}

\section{Table Woes}

{\setlength{\LTcapwidth}{\dimexpr0.6\textwidth + 10\tabcolsep\relax}
\begin{longtable}{@{}*{6}{>{\arraybackslash}p{0.10\linewidth}}@{}}
\caption{Caption needs to be left aligned beginning at same starting position as table}
\label{tab:longtable_captionlable}\\
\toprule
Col 1 & Col 2 & Col 3 & Col 4 & Col 5 & Col 6 \\
\midrule
1 & 2 & 3 & 4 & 5 & 6 \\
1 & 2 & 3 & 4 & 5 & 6 \\
1 & 2 & 3 & 4 & 5 & 6 \\
\bottomrule
\end{longtable}}

\begin{table}[h]
\begin{floatrow}
\ttabbox
{\caption{Using floatrow, caption is properly left aligned from the beginning of left table margin.}\label{tab:table_captionlable}}
{\begin{tabular}{|p{0.10\textwidth}|p{0.10\textwidth}|p{0.10\textwidth}|p{0.10\textwidth}|p{0.10\textwidth}|p{0.10\textwidth}|}
\hline
Col 1 & Col 2 & Col 3 & Col 4 & Col 5 & Col 6 \\
\hline
1 & 2 & 3 & 4 & 5 & 6 \\
1 & 2 & 3 & 4 & 5 & 6 \\
1 & 2 & 3 & 4 & 5 & 6 \\
\hline
\end{tabular}}%
\end{floatrow}
\end{table}

\end{document}


• Why you in the first table you add \arraybackslash to each p{...}, i.e. what make >{\arraybackslash}p{...} possible? – Zarko Dec 26 '16 at 21:12
• It was so in the O.P., and I didn't think of changing it… But you made me think of simplifying the table preamble. – Bernard Dec 26 '16 at 21:27