|
| 1 | +\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere |
| 2 | +\PassOptionsToPackage{hyphens}{url} |
| 3 | +% |
| 4 | +\documentclass[ |
| 5 | +]{article} |
| 6 | +\usepackage{lmodern} |
| 7 | +\usepackage{amssymb,amsmath} |
| 8 | +\usepackage{ifxetex,ifluatex} |
| 9 | +\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex |
| 10 | + \usepackage[T1]{fontenc} |
| 11 | + \usepackage[utf8]{inputenc} |
| 12 | + \usepackage{textcomp} % provides euro and other symbols |
| 13 | +\else % if luatex or xelatex |
| 14 | + \usepackage{unicode-math} |
| 15 | + \defaultfontfeatures{Scale=MatchLowercase} |
| 16 | + \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} |
| 17 | +\fi |
| 18 | +% use upquote if available, for straight quotes in verbatim environments |
| 19 | +\IfFileExists{upquote.sty}{\usepackage{upquote}}{} |
| 20 | +\IfFileExists{microtype.sty}{% use microtype if available |
| 21 | + \usepackage[]{microtype} |
| 22 | + \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts |
| 23 | +}{} |
| 24 | +\makeatletter |
| 25 | +\@ifundefined{KOMAClassName}{% if non-KOMA class |
| 26 | + \IfFileExists{parskip.sty}{% |
| 27 | + \usepackage{parskip} |
| 28 | + }{% else |
| 29 | + \setlength{\parindent}{0pt} |
| 30 | + \setlength{\parskip}{6pt plus 2pt minus 1pt}} |
| 31 | +}{% if KOMA class |
| 32 | + \KOMAoptions{parskip=half}} |
| 33 | +\makeatother |
| 34 | +\usepackage{xcolor} |
| 35 | +\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available |
| 36 | +\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}} |
| 37 | +\hypersetup{ |
| 38 | + pdftitle={Tests for table-short-captions.lua}, |
| 39 | + pdfborder={0 0 0}, |
| 40 | + breaklinks=true} |
| 41 | +\urlstyle{same} % don't use monospace font for urls |
| 42 | +\usepackage{longtable,booktabs} |
| 43 | +% Allow footnotes in longtable head/foot |
| 44 | +\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}} |
| 45 | +\makesavenoteenv{longtable} |
| 46 | +\setlength{\emergencystretch}{3em} % prevent overfull lines |
| 47 | +\providecommand{\tightlist}{% |
| 48 | + \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} |
| 49 | +\setcounter{secnumdepth}{-2} |
| 50 | +% Redefines (sub)paragraphs to behave more like sections |
| 51 | +\ifx\paragraph\undefined\else |
| 52 | + \let\oldparagraph\paragraph |
| 53 | + \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}} |
| 54 | +\fi |
| 55 | +\ifx\subparagraph\undefined\else |
| 56 | + \let\oldsubparagraph\subparagraph |
| 57 | + \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} |
| 58 | +\fi |
| 59 | + |
| 60 | +% set default figure placement to htbp |
| 61 | +\makeatletter |
| 62 | +\def\fps@figure{htbp} |
| 63 | +\makeatother |
| 64 | + |
| 65 | +% -- begin:latex-table-short-captions -- |
| 66 | +\makeatletter\AtBeginDocument{% |
| 67 | +\def\LT@c@ption#1[#2]#3{% % Overwrite the workhorse macro used in formatting a longtable caption. |
| 68 | + \LT@makecaption#1\fnum@table{#3}% |
| 69 | + \ifdefined\pandoctableshortcapt % If pandoctableshortcapt is defined (even if blank), we should override default behaviour. |
| 70 | + \let\@tempa\pandoctableshortcapt% % (Use let, we don't want to expand pandoctableshortcapt!) |
| 71 | + \else % If not, fall back to default behaviour |
| 72 | + \def\@tempa{#2}% % (Use the argument in square brackets) |
| 73 | + \fi |
| 74 | + \ifx\@tempa\@empty\else % If @tempa is blank, no lot entry! Otherwise, @tempa becomes the lot title. |
| 75 | + {\let\\\space |
| 76 | + \addcontentsline{lot}{table}{\protect\numberline{\thetable}{\@tempa}}}% |
| 77 | + \fi} |
| 78 | +}\makeatother |
| 79 | +% -- end:latex-table-short-captions -- |
| 80 | +\makeatletter |
| 81 | +\@ifpackageloaded{subfig}{}{\usepackage{subfig}} |
| 82 | +\@ifpackageloaded{caption}{}{\usepackage{caption}} |
| 83 | +\captionsetup[subfloat]{margin=0.5em} |
| 84 | +\AtBeginDocument{% |
| 85 | +\renewcommand*\figurename{Figure} |
| 86 | +\renewcommand*\tablename{Table} |
| 87 | +} |
| 88 | +\AtBeginDocument{% |
| 89 | +\renewcommand*\listfigurename{List of Figures} |
| 90 | +\renewcommand*\listtablename{List of Tables} |
| 91 | +} |
| 92 | +\@ifpackageloaded{float}{}{\usepackage{float}} |
| 93 | +\floatstyle{ruled} |
| 94 | +\@ifundefined{c@chapter}{\newfloat{codelisting}{h}{lop}}{\newfloat{codelisting}{h}{lop}[chapter]} |
| 95 | +\floatname{codelisting}{Listing} |
| 96 | +\newcommand*\listoflistings{\listof{codelisting}{List of Listings}} |
| 97 | +\makeatother |
| 98 | + |
| 99 | +\title{Tests for table-short-captions.lua} |
| 100 | +\date{} |
| 101 | + |
| 102 | +\begin{document} |
| 103 | +\maketitle |
| 104 | + |
| 105 | +\listoftables |
| 106 | +These tests are written so that if \textbf{bold font} appears in the |
| 107 | +LOT, something is wrong. |
| 108 | + |
| 109 | +The tests are split into two: expected uses, and non-standard |
| 110 | +uses/errors.\\ |
| 111 | +The non-standard uses are presented in this document for troubleshooting |
| 112 | +purposes, and to ensure the filter doesn't crash in corner cases. |
| 113 | + |
| 114 | +\hypertarget{standard-usage}{% |
| 115 | +\section{Standard usage}\label{standard-usage}} |
| 116 | + |
| 117 | +\begin{longtable}[]{@{}ll@{}} |
| 118 | +\caption{This is the \emph{italicised long caption} of tbl1, which does |
| 119 | +not have a label.}\tabularnewline |
| 120 | +\toprule |
| 121 | +cola & colb\tabularnewline |
| 122 | +\midrule |
| 123 | +\endfirsthead |
| 124 | +\toprule |
| 125 | +cola & colb\tabularnewline |
| 126 | +\midrule |
| 127 | +\endhead |
| 128 | +a1 & b1\tabularnewline |
| 129 | +a2 & b2\tabularnewline |
| 130 | +\bottomrule |
| 131 | +\end{longtable} |
| 132 | + |
| 133 | +\hypertarget{tbl:tbl-label2}{} |
| 134 | +\begin{longtable}[]{@{}ll@{}} |
| 135 | +\caption{\label{tbl:tbl-label2}This is the \emph{italicised long |
| 136 | +caption} of tbl2, in standard \texttt{pandoc-crossref} |
| 137 | +form.}\tabularnewline |
| 138 | +\toprule |
| 139 | +cola & colb\tabularnewline |
| 140 | +\midrule |
| 141 | +\endfirsthead |
| 142 | +\toprule |
| 143 | +cola & colb\tabularnewline |
| 144 | +\midrule |
| 145 | +\endhead |
| 146 | +a1 & b1\tabularnewline |
| 147 | +a2 & b2\tabularnewline |
| 148 | +\bottomrule |
| 149 | +\end{longtable} |
| 150 | + |
| 151 | +\def\pandoctableshortcapt{} % .unlisted |
| 152 | + |
| 153 | +\hypertarget{tbl:tbl-label3}{} |
| 154 | +\begin{longtable}[]{@{}ll@{}} |
| 155 | +\caption{\label{tbl:tbl-label3}This is the \emph{italicised long |
| 156 | +caption} of tbl3, which is \textbf{unlisted}.}\tabularnewline |
| 157 | +\toprule |
| 158 | +cola & colb\tabularnewline |
| 159 | +\midrule |
| 160 | +\endfirsthead |
| 161 | +\toprule |
| 162 | +cola & colb\tabularnewline |
| 163 | +\midrule |
| 164 | +\endhead |
| 165 | +a1 & b1\tabularnewline |
| 166 | +a2 & b2\tabularnewline |
| 167 | +\bottomrule |
| 168 | +\end{longtable} |
| 169 | + |
| 170 | +\undef\pandoctableshortcapt |
| 171 | + |
| 172 | +\def\pandoctableshortcapt{Table 4 \emph{short} capt.} |
| 173 | + |
| 174 | +\hypertarget{tbl:tbl-label4}{} |
| 175 | +\begin{longtable}[]{@{}ll@{}} |
| 176 | +\caption{\label{tbl:tbl-label4}This is the \emph{italicised long |
| 177 | +caption} of tbl4, which has an \textbf{overriding} short-caption. This |
| 178 | +is the expected usage.}\tabularnewline |
| 179 | +\toprule |
| 180 | +cola & colb\tabularnewline |
| 181 | +\midrule |
| 182 | +\endfirsthead |
| 183 | +\toprule |
| 184 | +cola & colb\tabularnewline |
| 185 | +\midrule |
| 186 | +\endhead |
| 187 | +a1 & b1\tabularnewline |
| 188 | +a2 & b2\tabularnewline |
| 189 | +\bottomrule |
| 190 | +\end{longtable} |
| 191 | + |
| 192 | +\undef\pandoctableshortcapt |
| 193 | + |
| 194 | +\hypertarget{non-standard-usageerrors}{% |
| 195 | +\section{Non-standard usage/errors}\label{non-standard-usageerrors}} |
| 196 | + |
| 197 | +\begin{longtable}[]{@{}ll@{}} |
| 198 | +\caption{This is the \emph{italicised long caption} of tbl5, which does |
| 199 | +not have a label, but does have empty braces at the end. |
| 200 | +\{\}}\tabularnewline |
| 201 | +\toprule |
| 202 | +cola & colb\tabularnewline |
| 203 | +\midrule |
| 204 | +\endfirsthead |
| 205 | +\toprule |
| 206 | +cola & colb\tabularnewline |
| 207 | +\midrule |
| 208 | +\endhead |
| 209 | +a1 & b1\tabularnewline |
| 210 | +a2 & b2\tabularnewline |
| 211 | +\bottomrule |
| 212 | +\end{longtable} |
| 213 | + |
| 214 | +\begin{longtable}[]{@{}ll@{}} |
| 215 | +\caption{This is the \emph{italicised long caption} of tbl6, which does |
| 216 | +not have a label, but does have an empty span at the end. |
| 217 | +}\tabularnewline |
| 218 | +\toprule |
| 219 | +cola & colb\tabularnewline |
| 220 | +\midrule |
| 221 | +\endfirsthead |
| 222 | +\toprule |
| 223 | +cola & colb\tabularnewline |
| 224 | +\midrule |
| 225 | +\endhead |
| 226 | +a1 & b1\tabularnewline |
| 227 | +a2 & b2\tabularnewline |
| 228 | +\bottomrule |
| 229 | +\end{longtable} |
| 230 | + |
| 231 | +\begin{longtable}[]{@{}ll@{}} |
| 232 | +\caption{This is the \emph{italicised long caption} of tbl7, which is |
| 233 | +improperly formatted, and will appear in the list of tables. This filter |
| 234 | +requires that \texttt{.unlisted} is placed in a span. \{\#tbl:tbl-label7 |
| 235 | +.unlisted\}}\tabularnewline |
| 236 | +\toprule |
| 237 | +cola & colb\tabularnewline |
| 238 | +\midrule |
| 239 | +\endfirsthead |
| 240 | +\toprule |
| 241 | +cola & colb\tabularnewline |
| 242 | +\midrule |
| 243 | +\endhead |
| 244 | +a1 & b1\tabularnewline |
| 245 | +a2 & b2\tabularnewline |
| 246 | +\bottomrule |
| 247 | +\end{longtable} |
| 248 | + |
| 249 | +\hypertarget{tbl:tbl-label8}{} |
| 250 | +\begin{longtable}[]{@{}ll@{}} |
| 251 | +\caption{\label{tbl:tbl-label8}This is the \emph{italicised long |
| 252 | +caption} of tbl8, which has an empty short-caption. An empty |
| 253 | +short-caption does nothing. The long caption will still be |
| 254 | +used.}\tabularnewline |
| 255 | +\toprule |
| 256 | +cola & colb\tabularnewline |
| 257 | +\midrule |
| 258 | +\endfirsthead |
| 259 | +\toprule |
| 260 | +cola & colb\tabularnewline |
| 261 | +\midrule |
| 262 | +\endhead |
| 263 | +a1 & b1\tabularnewline |
| 264 | +a2 & b2\tabularnewline |
| 265 | +\bottomrule |
| 266 | +\end{longtable} |
| 267 | + |
| 268 | +\def\pandoctableshortcapt{} % .unlisted |
| 269 | + |
| 270 | +\hypertarget{tbl:tbl-label9}{} |
| 271 | +\begin{longtable}[]{@{}ll@{}} |
| 272 | +\caption{\label{tbl:tbl-label9}This is the \emph{italicised long |
| 273 | +caption} of tbl9, which is \textbf{unlisted}, yet has a |
| 274 | +short-caption.}\tabularnewline |
| 275 | +\toprule |
| 276 | +cola & colb\tabularnewline |
| 277 | +\midrule |
| 278 | +\endfirsthead |
| 279 | +\toprule |
| 280 | +cola & colb\tabularnewline |
| 281 | +\midrule |
| 282 | +\endhead |
| 283 | +a1 & b1\tabularnewline |
| 284 | +a2 & b2\tabularnewline |
| 285 | +\bottomrule |
| 286 | +\end{longtable} |
| 287 | + |
| 288 | +\undef\pandoctableshortcapt |
| 289 | + |
| 290 | +\end{document} |
0 commit comments