0

I have a table that marks if the table is moved to the next page. But for some reason, the title of the table moves to the right. What's the reason? The code and the screenshot below.

Thanks in advance.

\setlength\tabcolsep{4pt}
\begin{longtable}{p{2.5cm}p{10cm}}
\label{tab:Table caption positioning}
\caption{Table caption shifted from center by unknown reason}\\
\endfirsthead
\multicolumn{2}{c}%
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
\endhead
\hline \multicolumn{2}{r}{\textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot
\hline
\textbf{Cell11}  &  Cell12\\
\textbf{Cell21}  &  Cell22\\
\textbf{Cell31}  &  Cell32\\
\textbf{Cell41}  &  Cell42\\
\textbf{Cell51}  &  Cell52\\
\textbf{Cell61}  &  Cell62\\
\textbf{Cell71}  &  Cell72\\
\textbf{Cell81}  &  Cell82\\
\textbf{Cell91}  &  Cell92\\
\textbf{Cell101}  &  Cell102\\
\textbf{Cell111}  &  Cell112\\
\textbf{Cell121}  &  Cell122\\
\textbf{Cell131}  &  Cell132\\
\textbf{Cell141}  &  Cell142\\
\hline
\end{longtable}

shifted caption in longtable

4
  • 1
    Welcome to TeX.SE. Did you run LaTeX twice?
    – Mico
    Commented Jun 4, 2020 at 12:11
  • @Mico Yes, many times.
    – Texo
    Commented Jun 4, 2020 at 12:17
  • You have to provide an MWE. I compiled your table using Overleaf, and it compiled fine. I assume you are using the caption package (or KOMA-script) without correct options.
    – Sveinung
    Commented Jun 4, 2020 at 14:29
  • Table label should always be after caption.
    – Zarko
    Commented Mar 2, 2021 at 5:32

1 Answer 1

1

I compiled your longtable using Overleaf, and it compiled fine. I assume you are using the caption package (or KOMA-script) without correct options. (I moved the label inside the caption to get rid of an error message and assure that the reference will be correct)

Here is the MWE:

\documentclass{article}
\usepackage{longtable, lmodern}
\setlength\tabcolsep{4pt}

\begin{document}

\begin{longtable}{p{2.5cm}p{10cm}}
\caption{Table caption shifted from center by unknown reason\label{tab:Table caption positioning}}\\
\endfirsthead
\multicolumn{2}{c}%
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
\endhead
\hline \multicolumn{2}{r}{\textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot
\hline
\textbf{Cell11}  &  Cell12\\
\textbf{Cell21}  &  Cell22\\
\textbf{Cell31}  &  Cell32\\
\textbf{Cell41}  &  Cell42\\
\textbf{Cell51}  &  Cell52\\
\textbf{Cell61}  &  Cell62\\
\textbf{Cell71}  &  Cell72\\
\textbf{Cell81}  &  Cell82\\
\textbf{Cell91}  &  Cell92\\
\textbf{Cell101}  &  Cell102\\
\textbf{Cell111}  &  Cell112\\
\textbf{Cell121}  &  Cell122\\
\textbf{Cell131}  &  Cell132\\
\textbf{Cell141}  &  Cell142\\
\textbf{Cell11}  &  Cell12\\
\textbf{Cell21}  &  Cell22\\
\textbf{Cell31}  &  Cell32\\
\textbf{Cell41}  &  Cell42\\
\textbf{Cell51}  &  Cell52\\
\textbf{Cell61}  &  Cell62\\
\textbf{Cell71}  &  Cell72\\
\textbf{Cell81}  &  Cell82\\
\textbf{Cell91}  &  Cell92\\
\textbf{Cell101}  &  Cell102\\
\textbf{Cell111}  &  Cell112\\
\textbf{Cell121}  &  Cell122\\
\textbf{Cell131}  &  Cell132\\
\textbf{Cell141}  &  Cell142\\\textbf{Cell11}  &  Cell12\\
\textbf{Cell21}  &  Cell22\\
\textbf{Cell31}  &  Cell32\\
\textbf{Cell41}  &  Cell42\\
\textbf{Cell51}  &  Cell52\\
\textbf{Cell61}  &  Cell62\\
\textbf{Cell71}  &  Cell72\\
\textbf{Cell81}  &  Cell82\\
\textbf{Cell91}  &  Cell92\\
\textbf{Cell101}  &  Cell102\\
\textbf{Cell111}  &  Cell112\\
\textbf{Cell121}  &  Cell122\\
\textbf{Cell131}  &  Cell132\\
\textbf{Cell141}  &  Cell142\\\textbf{Cell11}  &  Cell12\\
\textbf{Cell21}  &  Cell22\\
\textbf{Cell31}  &  Cell32\\
\textbf{Cell41}  &  Cell42\\
\textbf{Cell51}  &  Cell52\\
\textbf{Cell61}  &  Cell62\\
\textbf{Cell71}  &  Cell72\\
\textbf{Cell81}  &  Cell82\\
\textbf{Cell91}  &  Cell92\\
\textbf{Cell101}  &  Cell102\\
\textbf{Cell111}  &  Cell112\\
\textbf{Cell121}  &  Cell122\\
\textbf{Cell131}  &  Cell132\\
\textbf{Cell141}  &  Cell142\\\textbf{Cell11}  &  Cell12\\
\textbf{Cell21}  &  Cell22\\
\textbf{Cell31}  &  Cell32\\
\textbf{Cell41}  &  Cell42\\
\textbf{Cell51}  &  Cell52\\
\textbf{Cell61}  &  Cell62\\
\textbf{Cell71}  &  Cell72\\
\textbf{Cell81}  &  Cell82\\
\textbf{Cell91}  &  Cell92\\
\textbf{Cell101}  &  Cell102\\
\textbf{Cell111}  &  Cell112\\
\textbf{Cell121}  &  Cell122\\
\textbf{Cell131}  &  Cell132\\
\textbf{Cell141}  &  Cell142\\
\hline
\end{longtable}
\end{document} 

And here is the output:

enter image description here enter image description here

2
  • Thanks a lot! The problem is fixed by putting "\label" inside the "\caption" as you did, i. e. changing "\label{tab:Table caption positioning} \caption{Table caption shifted from center by unknown reason}\\" to "\caption{Table caption shifted from center by unknown reason\label{tab:Table caption positioning}}\\"
    – Texo
    Commented Jun 5, 2020 at 17:13
  • It also work correctly with \caption{Table caption shifted from center by unknown reason}\label{tab:Table caption positioning}\\
    – Zarko
    Commented Jun 30, 2021 at 7:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .