1

I'm using the longtable package for a document of the memoir class and I adjusted the Figure captions to be bold (e.g. "Figure 1:"). Now, I tried to achieve the same for the longtable caption but don't get it right, i.e. I want to have the table name in bold as well (like "Table 1:"). Since I'm using memoir I'd like to avoid including \usepackage{caption}. At the same time, longtable requires the \caption{} command to be the first command within the environment, that's why I can not simply define a new caption command via \newcommand with the memoir specific parameters for captions.

I guess I have to tweek the longtable command \LT@makecaption directly but my LaTeX/Tex skills are simply too little to do so. Does anybody know how to proceed?

Once the caption is bold I guess this shows me how I can also get it not centered anymore ...

Here is a MWE that outputs a tiny longtable with the caption name in normal font and centered:

\documentclass[a4paper,11pt,oldfontcommands]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{longtable}
\begin{document}
  \begin{longtable}{rr}
    \caption{A simple longtable} \\
    \hline
    First col & Second col \\ \hline 
    \endfirsthead

    \multicolumn{2}{c}%
    {\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
    \hline
    First col & Second col \\
    \hline
    \endhead

    \hline \multicolumn{2}{r}{\textit{Continued on next page}} \\
    \endfoot
    \hline
    \endlastfoot

    1 & 2 \\
    1 & 2 \\
    1 & 2 \\
    1 & 2 \\

  \end{longtable}
\end{document}

Many thanks in advance for any help!

5
  • 1
    Welcome to TeX SX! Please post a full minimal example, with the preamble you have.
    – Bernard
    Jan 8 '18 at 19:10
  • i'm not sure what you like to achive ... see if \captionstyle[\raggedright]{\centerlastline} in preamble gives what you looking for.
    – Zarko
    Jan 8 '18 at 19:40
  • @Bernard sorry for that! The example should be complete now.
    – Kolja
    Jan 8 '18 at 20:01
  • @Zarko sorry for the inaccuracy. I edited my post to make it clearer. I want to have the name of the table, i.e. "Table 1:" in bold. Moreover, in default setting the longtable is centered, so the caption is centered as well. For short captions, this looks odd because the caption does not start left-justified as all other captions.
    – Kolja
    Jan 8 '18 at 20:11
  • @Kolja, see my answer below. my suggestion works, however, you also need to adjust \LTcapwidth
    – Zarko
    Jan 8 '18 at 23:20
2

i guess that you looking for something like this:

enter image description here

(red lines show page layout), mwe, which generate this image, is:

\documentclass[a4paper,11pt]{memoir}
\captionstyle[\raggedright]{\centerlastline}    % <--- added
\captionnamefont{\bfseries}                     % <--- added
\usepackage{longtable}
\setlength\LTcapwidth{\linewidth}               % <--- added

%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}

\begin{document}
\lipsum[11]
  \begin{longtable}{rr}
    \caption{A simple longtable} \\
    \hline
    First col & Second col \\
    \hline
    \endfirsthead
    \multicolumn{2}{c}%
    {\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
    \hline
    First col & Second col \\
    \hline
    \endhead
    \hline
    \multicolumn{2}{r}{\textit{Continued on next page}} \\
    \endfoot
    \hline
    \endlastfoot
    1 & 2 \\
    1 & 2 \\
    1 & 2 \\
    1 & 2 \\
  \end{longtable}
\end{document}

changes in comparison to your mwe are indicated by % <--- added.

note: if you like to have caption of table on the next page positioned on the same way, you need to replace

   \multicolumn{2}{c}%
    {\tablename\ \thetable\ -- \textit{Continued from previous page}} \\

with

    \caption{A simple longtable \textit{Continued from previous page}} \\
2
  • Awesome! I did not expect it to be that easy but that is even better. That is exactly what I was looking for.
    – Kolja
    Jan 9 '18 at 4:37
  • @Kolja, than you can accept answer (by clicking on check mark at top left side of answer) :-)
    – Zarko
    Jan 9 '18 at 4:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.