Skip to content

Commit 7a49118

Browse files
blake-rileytarleb
authored andcommitted
Fix pandoc#48 by using \let=\relax and \@ifundefined
Previously, the code injected into the preamble assumed that etoolbox was loaded. If it wasn't, \undef remained undefined. By using \@ifundefined (a standard LaTeX command), we can use \let\func\relax in place of \undef\func.
1 parent b7f6f1a commit 7a49118

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

table-short-captions/table-short-captions.lua

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ longtable_caption_mod = [[
3030
\makeatletter\AtBeginDocument{%
3131
\def\LT@c@ption#1[#2]#3{% % Overwrite the workhorse macro used in formatting a longtable caption.
3232
\LT@makecaption#1\fnum@table{#3}%
33-
\ifdefined\pandoctableshortcapt % If pandoctableshortcapt is defined (even if blank), we should override default behaviour.
34-
\let\@tempa\pandoctableshortcapt% % (Use let, we don't want to expand pandoctableshortcapt!)
35-
\else % If not, fall back to default behaviour
36-
\def\@tempa{#2}% % (Use the argument in square brackets)
37-
\fi
33+
\@ifundefined{pandoctableshortcapt}
34+
{\def\@tempa{#2}} % Use default behaviour: argument in square brackets
35+
{\let\@tempa\pandoctableshortcapt} % If defined (even if blank), use to override
3836
\ifx\@tempa\@empty\else % If @tempa is blank, no lot entry! Otherwise, @tempa becomes the lot title.
3937
{\let\\\space
4038
\addcontentsline{lot}{table}{\protect\numberline{\thetable}{\@tempa}}}%
@@ -60,7 +58,7 @@ local function defshortcapt(sc)
6058
end
6159

6260
--- The undef shortcaption block to be placed after the table
63-
local undefshortcapt = pandoc.RawBlock('tex', "\\undef\\pandoctableshortcapt")
61+
local undefshortcapt = pandoc.RawBlock('tex', "\\let\\pandoctableshortcapt\\relax")
6462

6563
--- Parses a mock "Table Attr".
6664
-- We use the Attr of an empty Span as if it were Table Attr.

0 commit comments

Comments
 (0)