0

I'd like to know how to remove the margin of the longtable caption (\captionsetup[longtable]{margin=0pt}) without crossing the margin given by the showframe package.

Actually, I think my caption has been shifted on the left of the page, because it has the expected width of the page.

See the figure below.

The problem appears on my computer but also on overleaf.

My version is Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex 2016.4.19).

Overleaf works on Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex 2017.11.22).

\documentclass[12pt,french]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{multirow}
\usepackage{xspace}
\usepackage{longtable}
\usepackage{showframe}
\usepackage{lipsum}
\usepackage{babel}
\usepackage{caption}
\captionsetup[longtable]{margin=4pt}
\begin{document}
\lipsum[1]
\begin{longtable}{c}
\multicolumn{1}{c}{Item} \\ \hline
\endfirsthead

\multicolumn{1}{c}%
{{\bfseries \tablename\ \thetable{} -- suite}} \\
\hline \multicolumn{1}{c}{Item}  \\ \hline
\endhead

\hline %\multicolumn{3}{|r|}{{Continued on next page}} \\ \hline
\endfoot

\hline % \hline
\caption{Test test test test test test test test test test test test test test test test.Test test test test test test test test test test test test test test test test.}
  \label{tableau1}
\endlastfoot
1 \\
2\\
\end{longtable}

\lipsum[1]
\end{document}

Illustration

2
  • Can you please clarify your expectation. The statement margin of the longtable caption (\captionsetup[longtable]{margin=0pt}) without crossing the margin given by the showframe package. is not clear Dec 6, 2017 at 8:35
  • I used the showframe to see my text zones of the page. After compilation, you'll see the caption ouside this zone, a few points shifted on the left. Dec 6, 2017 at 8:44

1 Answer 1

3

The problem are the spurious spaces after your \caption command. They push the caption a bit to the left:

\documentclass[12pt,french]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{multirow}
\usepackage{xspace}
\usepackage{longtable}
\usepackage{showframe}
\usepackage{lipsum}
\usepackage{babel}
\usepackage{caption}
\captionsetup[longtable]{margin=0pt}
\begin{document}
\lipsum[1]
\begin{longtable}{c}
 \caption{Test test test test test test test test test test test test test
 test test test.Test test test test test test test test test
 test test test test test test test.}%<---
\label{tableau1}%<----
\endlastfoot
1 \\
2\\
\end{longtable}


\begin{longtable}{c}
\caption{Test test test test test test test test test test test test test
 test test test.Test test test test test test test test test
 test test test test test test test.} %<---
\label{tableau1} %<----
\endlastfoot
1 \\
2\\
\end{longtable}

\lipsum[1]
\end{document}

enter image description here

1
  • Thanks Ulrike... Deleted my answer... I could never find out by myself that the problematic code was not inside the MWE...
    – koleygr
    Dec 6, 2017 at 11:29

You must log in to answer this question.

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