3

I have to prepare several long tables in a conference proceeding book. Editor told me that I had to suppress captions of long tables on odd pages.

Is it possible?

EDIT: Minimal working example here:

\documentclass[a4paper, 10pt, oneside,hidelinks]{book} 
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\usepackage{booktabs,array,tabularx}
\usepackage{graphicx,lscape}
\usepackage{tabu}
\usepackage{longtable}
\usepackage[font={small}]{caption}
\DeclareCaptionLabelFormat{viadot}{\textbf{\small #1 #2.}}
\captionsetup{labelsep=space, labelformat=viadot}

\begin{document}

\begin{landscape}
  \small
\begin{longtabu} to \linewidth{ lll XX  XXXXX}

 \caption*{ Long caption of a long table}\\
 \toprule
 1 & 2& 3&4&5&6&7&8\\
 \midrule
 \endfirsthead
 \caption*{ (Cont) Long caption of a long table }\\
 \toprule
 1 & 2& 3&4&5&6&7&8\\
 \midrule

  \endhead




  \bottomrule
  \endfoot

  \bottomrule
  \endlastfoot




1-й

 & Длина, мм & Самцы & —
 & 85,1--104,0 93,7 (6) & 100,6 (1) & —
 & —
 & —
 & —
 \\ &  & Самки & —
 & 92,1--105,8 97,6 (4) & 137,6 (1) & —
 & —
 & —
 & —
 \\ 
 &  & juv & 43,6–82,0 53,3 (20) & —
 & —
 & —
 & —
 & —
 & —
 \\ 
 & Масса, г & Самцы & —
 & 2,3--4,2 \linebreak2,8 (6) & 3,2 (1) & —
 & —
 & —
 & —
 \\ 
 &  & Самки & —
 & 2,2--3,6\linebreak 2,7 (4) & 7,9 (1) & —
 & —
 & —
 & —
 \\ 
 &  & juv & 0,2--1,8\linebreak 0,4 (20) & —
 & —
 & —
 & —
 & —
 & —
 \\ 
\\

2-й & Длина, мм & Самцы & —
 & 72,0--114,0
93,6 (16) & 104,3--132,3
113,4 (4) & 121,5--178,2
139,3 (9) & 
158,9 (1) & 193,7--212,7
175,6 (3) & —
 \\ 
 &  & Самки & —
 & 77,5--110,4
95,2 (7) & 110,4--131,3
117,6 (4) & 167,8 (1) & —
 & 182,9 (1) & —
 \\ 
 &  & juv & 45,1--86,9
51,9 (40) & —
 & —
 & —
 & —
 & —
 & —
 \\ 
 & Масса, г & Самцы & —
 & 1,1--5,1 \linebreak 2,7 (16) & 3,7--5,5 \linebreak 4,3  (4) &
 5,1--15,0\linebreak  9,2 (9) 
 & 17,0 (1) & 21,0--30,0 26,3 (3) & —
 \\ 
 &  & Самки & —
 & 1,5--4,7
\linebreak2,8 (7) & 4,0--6,1
\linebreak5,1 (4) & 15,0 (1) & —
 & 34,0 (1) & —
 \\ 
 &  & juv & 0,2--1,3
\linebreak0,4 (40) & —
 & —
 & —
 & —
 & —
 & —
 \\ 

\\

3-й & Длина, мм & Самцы & —
 & 85,8--114,6
100,4 (7) & 113,7--131,2
118,3 (5) & 124,0--172,7
148,3 (2) & 144,6  (1)
 & —
 & 181,7--184,0
182,8 (2) \\ 
 &  & Самки & —
 & 84,7--115,7
98,0 (9) & 109,1--156,4
133,3 (3) & 106,9--167,1
140,0 (3) & 159,3 (1) & 222,6 (1) & 170,2 (1) \\ 
 &  & juv & 42,3--90,4
61,0 (26) & —
 & —
 & —
 & —
 & —
 & —
 \\ 
 & Масса, г & Самцы & —
 & 2,1--5,2
\linebreak3,7 (7) & 4,5--10,0
\linebreak5,8 (5) & 7,6--19,0
\linebreak13,3 (2) & 11,0 (1) & —
 & 23,5--24,9
24,2 (2) \\ 
 &  & Самки & —
 & 2,0--5,9
\linebreak3,5 (9) & 4,9--14,0
\linebreak9,7 (3) & 4,5--21,0
\linebreak12,5 (3) & 15,0 (1) & 39,0 (1) & 18,0 (1) \\ 
 &  & juv & 0,3--2,6
\linebreak0,9 (26) & —
 & —
 & —
 & —
 & —
 & —
 \\ 

\\

4-й & Длина, мм & Самцы & —
 & 77,6--112,0
92,7 (14) & 115,2--140,2
127,7 (2) & 135,2 (1) & 146,1--181,1
159,9 (3) & 157,9 (1) & 175,4--244,7
210,0 (2) \\ 
 &  & Самки & —
 & 88,0--113,7
99,1 (4) & 105,0--157,1
135,4 (6) & 123,0--174,3
141,3 (6) & 134,2--182,3
160,1 (3) & 181,6--187,0
183,4 (3) & —
 \\ 
 &  & juv & 43,9--81,0
52,0 (19) & —
 & —
 & —
 & —
 & —
 & —
 \\ 
 & Масса, г & Самцы & —
 & 1,2--5,0
\linebreak2,7 (14) & 5,0--12,0
\linebreak8,5 (2) & 10,9 (1) & 12,0--23,0
\linebreak16,6 (3) & 13,4 (1) & 17,0 (1) \\ 
 &  & Самки & —
 & 2,0--6,0
\linebreak3,2 (4) & 4,3--17,0
\linebreak9,3 (6) & 7,0--26,0
\linebreak13,0 (6) & 7,0--19,8
\linebreak14,4 (3) & 20,0--36,0
\linebreak25,3 (3) & —
 \\ 
 &  & juv & 0,2--2,3
\linebreak0,5 (19) & —
 & —
 & —
 & —
 & —
 & —
 \\ 
\\


5-й & Длина, мм & Самцы & —
 & 71,7--108,2
\linebreak91,3 (32) & 87,3--140,0
\linebreak110,6 (39) & 105,6--149,4
\linebreak126,8 (7) & 130,4--160,9
\linebreak149,6 (5) & 166,2 (1) & —
 \\ 
 &  & Самки & —
 & 80,2--105,4
\linebreak93,2 (30) & 93,6--152,9
\linebreak114,0 (48) & 123,0--147,1
\linebreak136,3 (12) & 144,2--147,0
\linebreak145,6 (2) & 140,7--179,6
\linebreak160,1 (2) & —
 \\ 
 &  & juv & 43,0--99,5
\linebreak73,1(47) & —
 & —
 & —
 & —
 & —
 & —
 \\ 
 & Масса, г & Самцы & —
 & 1,0--4,7
\linebreak2,6 (32) & 1,7--13,0
\linebreak4,6 (39) & 3,6--15,0
\linebreak8,37(7) & 9,1--21,0
\linebreak14,9 (5) & 11,6 (1) & —
 \\ 
 &  & Самки & —
 & 1,7--4,7
\linebreak2,9 (30) & 2,0--17,0
\linebreak5,5 (48) & 7,9--15,4
\linebreak10,9 (12) & 9,9--13,0
\linebreak11,4 (2) & 12,3--28,0
\linebreak20,1 (2) & —
 \\ 
 &  & juv & 0,2--4,2
\linebreak1,4 (47) & —
 & —
 & —
 & —
 & —
 & \multicolumn{1}{l}{—
} \\ 
 &  &  &  &  &  &  &  &  &  \\ 
\\


6-й & Длина, мм & Самцы & —
 & 61,0--147,4
\linebreak98,2 (19) & 104,1--166,3
\linebreak120,4 (27) & 119,1--189,3
\linebreak147,0 (12) & 139,0--175,4
\linebreak157,2 (3) & 176,6--215,0
\linebreak195,8 (2) & 199,1--267,0
\linebreak246,4 (5) \\ 
 &  & Самки & —
 & 78,2--139,6
\linebreak99,1 (15) & 93,3--162,4
\linebreak122,3 (23) & 119,0--177,0
\linebreak145,6 (6) & 145,8--169,7
\linebreak158,9 (4) & 203,6 (1) & 212,9 (1) \\ 
 &  & juv & 44,0--96,3
\linebreak64,4 (35) & —
 & —
 & —
 & —
 & —
 & —
 \\ 
 & Масса, г & Самцы & —
 & 1,3--13,0
\linebreak5,0 (15) & 2,7--14,0
\linebreak5,9 (27) & 6,5--24,0
\linebreak12,0 (12) & 9,0--9,8
\linebreak9,4 (2) & 18,0--38,0
\linebreak28,0  (2) & 19,6--73,0
\linebreak49,7 (5) \\ 
 &  & Самки & —
 & 1,6--11,0
\linebreak4,4 (12) & 1,8--13,0
\linebreak6,3 (23) & 5,6--16,0
\linebreak11,3 (5) & 10,7--18,0
\linebreak13,9 (4) & 34,0 (1) & 36,0 (1) \\ 
 &  & juv & 0,2--3,0
\linebreak1,3 (35) & —
 & —
 & —
 & —
 & —
 & —
 \\ 

\\

7-й & Длина, мм & Самцы & —
 & 69,6--131,3,5
\linebreak93,4 (39) & 83,5--159,1
\linebreak116,4 (41) & 105,4--181,8
\linebreak138,8 (14) & 132,0--168,0
\linebreak153,7 (5) & 134,9--178,9
\linebreak156,9 (2) & 193,5 (1) \\ 
 &  & Самки & —
 & 64,9--133,0
\linebreak88,2 (31) & 83,3--169,1
\linebreak121,6 (39) & 95,2--168,4
\linebreak136,9 (20) & 136,0--183,8
\linebreak158,8 (5) & 163,1--202,0
\linebreak177,1 (3) & 200,0 (1) \\ 
 &  & juv & 39,1--93,1
\linebreak61,3 (150) & —
 & —
 & —
 & —
 & —
 & —
 \\ 
 & Масса, г & Самцы & —
 & 1,0--9,0
\linebreak3,0 (39) & 1,8--17,0
\linebreak6,3 (41) & 4,1--34,0
\linebreak12,1 (14) & 8,4--21,7
\linebreak15,2 (5) & 9,1--22,0
\linebreak15,5 (2) & 39,0 (1) \\ 
 &  & Самки & — & 1,0--8,7
\linebreak2,3 (31) & 1,7--22,0
\linebreak7,6 (39) & 4,0--24,0
\linebreak11,3 (20) & 9,0--26,0
\linebreak17,6 (5) & 15,0--39,0
\linebreak23,5 (3) & 51,0 (1)
 \\ 
 &  & juv & 0,1--3,5
\linebreak0,8(150) & —
 & —
 & —
 & —
 & —
 & —
 \\
\\ 

Общее & Длина, мм & Самцы & —
 & 61,0--147,4
\linebreak93,6 (133) & 83,5--166,3
\linebreak115,5 (119) & 105,4--189,3
\linebreak140,4 (45) & 130,4--181,1
\linebreak153,9 (18) & 134,9--215,0
\linebreak178,9 (9) & 175,4--267,0
\linebreak221,1 (10) \\ 
 &  & Самки & —
 & 64,9--139,6
\linebreak93,5 (100) & 83,3--169,1
\linebreak119,7 (124) & 95,2--177,0
\linebreak139,1 (48) & 134,2--183,8
\linebreak157,4 (15) & 140,7--222,6
\linebreak182,8 (11) & 170,2--212,9
\linebreak194,4 (3) \\ 
 &  & juv & 39,1--99,5
\linebreak61,8 (337) & —
 & —
 & —
 & —
 & —
 & —
 \\ 
 & Масса, г & Самцы & —
 & 1,0--13,0
\linebreak3,1 (129) & 1,7--17,0
\linebreak5,8 (119) & 3,6 -34,0
\linebreak11,0  (45) & 8,4--23,0
\linebreak14,5 (17) & 9,1--38,0
\linebreak21,3 (9) & 17,0--73,0
\linebreak39,4 (9) \\ 
 &  & Самки & —
 & 1,0--11,0
\linebreak2,9  (97) & 1,7--22,0
\linebreak6,6  (124) & 4,0--26,0
\linebreak11,5 (47) & 7,0--26,0
\linebreak14,8 (15) & 12,3--39,0
\linebreak26,7 (11) & 18,5--51,0
\linebreak35,1 (3) \\ 
 &  & juv & 0,1--4,2
\linebreak0,9 (337) & —
 & —
 & —
 & —
 & —
 & —
 \\ 

\end{longtabu}
\end{landscape}


\end{document}

I want to get rid of catptions rounded by grey strokes
I want to get rid of catptions rounded by grey strokes

Mihail Kondratyev
  • 719
  • 1
  • 5
  • 8
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – cfr Sep 22 '14 at 23:08
  • Note that, as far as I can tell, longtable does not produce continuation captions by itself so unless you tell us how you are configuring captions, we really can't suggest how to do it differently. – cfr Sep 22 '14 at 23:18
  • I can't test, as tabu is not installed on my computer, but I would try this: load etoolbox and replace \caption*{ Long caption of a long table}\\ with \ifnumodd{\value{page}}{}{\caption*{ Long caption of a long table}\\}. Another solution would be to use the ifoddpage package and write checkoddpage\ifoddpage\else\caption*{ Long caption of a long table}\\\fi. Two runs will be necessary. – Bernard Sep 23 '14 at 00:28
  • Thanks for your answer, but it doesn't work. The file cannot be compiled neither I use etoolbox nor ifoddpage solving. – Mihail Kondratyev Sep 23 '14 at 01:51

1 Answers1

6

First of all, tricks like \caption{\ifoddpage \else \fi} should fail. This is because longtable typesets caption-text only one time, immediately after it reads \caption.

In fact, there are two boxes \LT@firsthead and \LT@head. when longtable reads \endfirsthead, it stores the current chunk in the box \LT@firsthead. Similarly when it reads \endhead it stores the current chunk in the box \LT@head.

So the I came up with the following

  • declare two new boxes \LT@oddhead and \LT@evenhead.
  • define \endoddhead and \endevenhead.
  • redefine \LT@head so that whenever longtable tries to access \LT@head, check the current page number and return \LT@oddhead or \LT@evenhead.

Hence the code

\documentclass{article}
\usepackage{longtable,setspace}\setstretch{10}
\begin{document}
\makeatletter
\newbox\LT@oddhead
\newbox\LT@evenhead
\def\endoddhead{\LT@end@hd@ft\LT@oddhead}
\def\endevenhead{\LT@end@hd@ft\LT@evenhead}
\def\LT@head{\ifodd\c@page\LT@oddhead\else\LT@evenhead}
\makeatother
\begin{longtable}{ccc}
    \caption{\Huge\bfseries FIRST PAGE}\endfirsthead
    \caption{\Huge\bfseries EVEN PAGE}\endevenhead
    \caption{\Huge\bfseries ODD PAGE}\endoddhead
    1 \\ 2 \\ 3 \\ 4 \\ 5 \\ 6 \\ 7 \\ 8 \\ 9 \\ 10 \\ 11 \\ 12 \\ 13 \\ 14 \\ 15 \\ 16 \\ 17 \\ 18 \\ 19 \\ 20 \\ 21 \\ 22 \\ 23 \\ 24 \\ 25 \\ 26 \\ 27 \\ 28 \\ 29 \\ 30 \\ \end{longtable}
\end{document}

Back to your code, it should be something like

\begin{document}
\makeatletter
\newbox\LT@oddhead
\newbox\LT@evenhead
\def\endoddhead{\LT@end@hd@ft\LT@oddhead}
\def\endevenhead{\LT@end@hd@ft\LT@evenhead}
\def\LT@head{\ifodd\c@page\LT@oddhead\else\LT@evenhead}
\makeatother
\begin{landscape}\small\begin{longtabu}to\linewidth{lll XX XXXXX}
    \caption*{ Long caption of a long table}\\\toprule1&2&3&4&5&6&7&8\\\midrule\endfirsthead
    \caption*{ (Cont) Long caption of a long table }\\\toprule1&2&3&4&5&6&7&8\\\midrule\endoddhead
    \toprule1&2&3&4&5&6&7&8\\\midrule\endevenhead

enter image description here

Symbol 1
  • 36,855
  • can you also get look at this http://tex.stackexchange.com/questions/202629/lasthead-section-in-a-longtabu-environment similar question. Maybe you have some ideas? – Mihail Kondratyev Sep 23 '14 at 22:38
  • +1 hey I was going to do that, can I forward all longtable bug^H^H^Hfeature requests to you:-) – David Carlisle Sep 24 '14 at 23:57
  • So glad I found this. Any chance it will ever actually be incorporated into longtable (along with the obvious footer variant)? – rpspringuel Dec 14 '18 at 16:10
  • @rpspringuel The author of [tag:longtable], David Carlisle, is right above you =). – Symbol 1 Dec 14 '18 at 16:31
  • Then I suppose I should have put @DavidCarlisle in my previous comment. Too late to edit, hopefully this is enough of a pointer. – rpspringuel Dec 14 '18 at 16:36
  • @rpspringuel it's listed as one of the things to do one day.. http://htmlpreview.github.io/?https://raw.githubusercontent.com/davidcarlisle/dpctex/master/longtable/ltbugs.html – David Carlisle Dec 14 '18 at 17:06