1

I need to move label text to the end of table caption, but there is newline at the end of text...

\documentclass[pdf, unicode, 12pt, a4paper, oneside, fleqn]{article}

\usepackage[utf8]{inputenc}
\usepackage[T2B]{fontenc}
\usepackage[english,russian]{babel}
\usepackage{caption}
\usepackage{longtable}


\DeclareCaptionFormat{reverse}{#3#2#1}
\DeclareCaptionLabelFormat{fullparens}{\bothIfFirst{#1}{ }#2}
\DeclareCaptionLabelSeparator{fill}{\hfill}
\captionsetup[longtable]{format=reverse,labelformat=fullparens,
              labelsep=fill}

\begin{document}

\begin{longtable}{|p{4.5cm}|p{11cm}|}
    \caption[Caption text]{Caption text} \label{table_1} \\
    \hline
    \endfirsthead
    \hline
    Title 1 & Title 2 \\
    \hline
    \endhead
    \hline
    \multicolumn{2}{c}{\textit{Продолжение на следующей странице}}
    \endfoot
    \hline
    \endlastfoot
    1 & 2 \\
\end{longtable}

\end{document}

And here is result: enter image description here Hot to remove new line? The result should be like this : "Text. Таблица 2".

  • Please extend your code snipped to complete small document, which we can copy and compile on our computers. – Zarko May 15 '17 at 1:34
  • Zarko, i extended my code. – toshunster May 15 '17 at 1:52
  • There are only two ways to put everything in one line: Put it all inside the \caption, or use \caption{} and put it all outside the caption. – John Kormylo May 15 '17 at 3:03
2

try the following caption formatting:

\DeclareCaptionFormat{reverse}{#3#2#1}
\DeclareCaptionLabelFormat{fullparens}{(\bothIfFirst{#1}{ }#2)\hfill}
\DeclareCaptionLabelSeparator{fill}{\vspace{-\baselineskip}\hfil\qquad }
\captionsetup{format=reverse,
              labelformat=fullparens,
              labelsep=fill, labelfont=bf}

enter image description here

or

enter image description here

Complete MWE producing the second caption is:

\documentclass[12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%\usepackage[english,russian]{babel}
\usepackage{caption}
\usepackage{longtable}


\DeclareCaptionFormat{reverse}{#3#2#1}
\DeclareCaptionLabelFormat{fullparens}{(\bothIfFirst{#1}{ }#2)\hfill}
\DeclareCaptionLabelSeparator{fill}{\vspace{-\baselineskip}\hfil\qquad }
\captionsetup{format=reverse,
              labelformat=fullparens,
              labelsep=fill, labelfont=bf}

\begin{document}

\begin{longtable}{|p{4.5cm}|p{11cm}|}
    \caption[Caption text]{Very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, long caption text.} \label{table_1} \\
    \hline
    \endfirsthead
    \hline
    Title 1 & Title 2 \\
    \hline
    \endhead
    \hline
    \multicolumn{2}{c}{\textit{xxxxxxxxx xxxxxxxxxxxxx}}
    \endfoot
    \hline
    \endlastfoot
    1 & 2 \\
\end{longtable}
\end{document}

If you like to have table label aligned with right border of table, than change definition for label separator to

\DeclareCaptionLabelSeparator{fill}{\vspace{-\baselineskip}\hfill}

in you will obtain:

enter image description here

| improve this answer | |
  • 1
    You can also use \captionsetup[longtable]... But I still see two lines. – John Kormylo May 15 '17 at 2:59
  • 1
    @JohnKormylo, I believe that caption setup is independent from longtable. I suggest dirty hack, since I don't know, how to remove par which is somewhere hidden in caption definition on the end of caption main text. – Zarko May 15 '17 at 3:08
  • @Zarko - One can setup figure, table and any other declared \@captype to use different formats. Then again, you don't have to. – John Kormylo May 15 '17 at 12: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.