From d79da60e6dcfb2f3d7c0a1f5abf9ee2bc684a15c Mon Sep 17 00:00:00 2001 In-Reply-To: <87wn93re80.fsf@t14.reltub.ca> References: <87wn93re80.fsf@t14.reltub.ca> From: Max Nikulin Date: Thu, 13 Oct 2022 22:08:29 +0700 Subject: [PATCH] ox-latex: Use \empty instead of \relax after \\ * lisp/ox-latex.el (org-latex-line-break-safe, org-latex-table-row): * testing/lisp/test-org-table.el (test-org-table/to-latex): Use \empty instead of \relax to prevent interpreting following "*" and "[" as optional parts of \\*[LENGTH] command. Fix regression introduced by 3f60acff77. \\\relax\hline caused misaligned \noalign error. Org markup: | a | |---| \hline is allowed only immediately after \cr while \relax has some side effects. Hope, \empty just expands to nothing. Those who used \\ optional argument to adjust amount of space between lines may add the following tricks: First,\\ @@latex:{\vskip1em}@@second. | First | | @@latex:\noalign{\vskip1em}@@second | Reported in gerard.vermeulen, Wed, 12 Oct 2022 03:15:49 +0000. https://list.orgmode.org/784cf8be450b7d676ddd60214cc847db@posteo.net --- lisp/ox-latex.el | 12 ++++++------ testing/lisp/test-org-table.el | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index eed5dc898..aff90f611 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -278,17 +278,17 @@ list can be: - `:lang-name' the actual name of the language.") -(defconst org-latex-line-break-safe "\\\\\\relax" +(defconst org-latex-line-break-safe "\\\\\\empty" "Linebreak protecting the following [...]. -Without \"\\relax\" it would be interpreted as an optional argument to +Without \"\\empty\" it would be interpreted as an optional argument to the \\\\. This constant, for example, makes the below code not err: \\begin{tabular}{c|c} - [t] & s\\\\\\relax - [I] & A\\\\\\relax + [t] & s\\\\\\empty + [I] & A\\\\\\empty [m] & kg \\end{tabular}") @@ -4005,9 +4005,9 @@ a communication channel." (org-export-get-parent-table table-row) info)))) (format "%s \\endfirsthead -\\multicolumn{%d}{l}{%s} \\\\\\relax +\\multicolumn{%d}{l}{%s} \\\\\\empty %s -%s \\\\\\relax\n +%s \\\\\\empty\n %s \\endhead %s\\multicolumn{%d}{r}{%s} \\\\ diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el index 3e7f18a10..722c37ea4 100644 --- a/testing/lisp/test-org-table.el +++ b/testing/lisp/test-org-table.el @@ -1635,11 +1635,11 @@ See also `test-org-table/copy-field'." (ert-deftest test-org-table/to-latex () "Test `orgtbl-to-latex' specifications." (should - (equal "\\begin{tabular}{l}\na\\\\\\relax\n\\end{tabular}" + (equal "\\begin{tabular}{l}\na\\\\\\empty\n\\end{tabular}" (orgtbl-to-latex (org-table-to-lisp "| a |") nil))) ;; Test :environment parameter. (should - (equal "\\begin{tabularx}{l}\na\\\\\\relax\n\\end{tabularx}" + (equal "\\begin{tabularx}{l}\na\\\\\\empty\n\\end{tabularx}" (orgtbl-to-latex (org-table-to-lisp "| a |") '(:environment "tabularx")))) ;; Test :booktabs parameter. @@ -1648,7 +1648,7 @@ See also `test-org-table/copy-field'." "\\toprule" (orgtbl-to-latex (org-table-to-lisp "| a |") '(:booktabs t)))) ;; Handle LaTeX snippets. (should - (equal "\\begin{tabular}{l}\n\\(x\\)\\\\\\relax\n\\end{tabular}" + (equal "\\begin{tabular}{l}\n\\(x\\)\\\\\\empty\n\\end{tabular}" (orgtbl-to-latex (org-table-to-lisp "| $x$ |") nil))) ;; Test pseudo objects and :raw parameter. (should -- 2.25.1