From b060f63078d65758f8fd2ab7725fbcf8b2de0057 Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko Date: Wed, 19 Oct 2022 11:48:26 +0800 Subject: [PATCH] org-latex-line-break-safe: Use safer value of "\\[0pt]" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/ox-latex.el (org-latex-line-break-safe): (org-latex-table-row): Change \empty ending to explicit optional argument. \empty still has undesired side effects in some cases. * testing/lisp/test-org-table.el (test-org-table/to-latex): * testing/lisp/test-ox-latex.el (test-ox-latex/verse): Update tests. Reported-by: Juan Manuel MacĂ­as Link: https://orgmode.org/list/87o7u9rz1a.fsf@posteo.net --- lisp/ox-latex.el | 12 ++++++------ testing/lisp/test-org-table.el | 6 +++--- testing/lisp/test-ox-latex.el | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index dc8477d14..a5652fd78 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -278,17 +278,17 @@ (defconst org-latex-language-alist - `:lang-name' the actual name of the language.") -(defconst org-latex-line-break-safe "\\\\\\empty" +(defconst org-latex-line-break-safe "\\\\[0pt]" "Linebreak protecting the following [...]. -Without \"\\empty\" it would be interpreted as an optional argument to +Without \"[0pt]\" 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\\\\\\empty - [I] & A\\\\\\empty + [t] & s\\\\[0pt] + [I] & A\\\\[0pt] [m] & kg \\end{tabular}") @@ -4005,9 +4005,9 @@ (defun org-latex-table-row (table-row contents info) (org-export-get-parent-table table-row) info)))) (format "%s \\endfirsthead -\\multicolumn{%d}{l}{%s} \\\\\\empty +\\multicolumn{%d}{l}{%s} \\\\[0pt] %s -%s \\\\\\empty\n +%s \\\\[0pt]\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 722c37ea4..573179878 100644 --- a/testing/lisp/test-org-table.el +++ b/testing/lisp/test-org-table.el @@ -1635,11 +1635,11 @@ (ert-deftest test-org-table/to-generic () (ert-deftest test-org-table/to-latex () "Test `orgtbl-to-latex' specifications." (should - (equal "\\begin{tabular}{l}\na\\\\\\empty\n\\end{tabular}" + (equal "\\begin{tabular}{l}\na\\\\[0pt]\n\\end{tabular}" (orgtbl-to-latex (org-table-to-lisp "| a |") nil))) ;; Test :environment parameter. (should - (equal "\\begin{tabularx}{l}\na\\\\\\empty\n\\end{tabularx}" + (equal "\\begin{tabularx}{l}\na\\\\[0pt]\n\\end{tabularx}" (orgtbl-to-latex (org-table-to-lisp "| a |") '(:environment "tabularx")))) ;; Test :booktabs parameter. @@ -1648,7 +1648,7 @@ (ert-deftest test-org-table/to-latex () "\\toprule" (orgtbl-to-latex (org-table-to-lisp "| a |") '(:booktabs t)))) ;; Handle LaTeX snippets. (should - (equal "\\begin{tabular}{l}\n\\(x\\)\\\\\\empty\n\\end{tabular}" + (equal "\\begin{tabular}{l}\n\\(x\\)\\\\[0pt]\n\\end{tabular}" (orgtbl-to-latex (org-table-to-lisp "| $x$ |") nil))) ;; Test pseudo objects and :raw parameter. (should diff --git a/testing/lisp/test-ox-latex.el b/testing/lisp/test-ox-latex.el index 4fb9f2888..adb3a60ea 100644 --- a/testing/lisp/test-ox-latex.el +++ b/testing/lisp/test-ox-latex.el @@ -60,14 +60,14 @@ (ert-deftest test-ox-latex/verse () (should (search-forward "\\begin{verse} -lorem ipsum dolor\\\\\\empty -lorem ipsum dolor\\\\\\empty +lorem ipsum dolor\\\\[0pt] +lorem ipsum dolor\\\\[0pt] \\vspace*{1em} -lorem ipsum dolor\\\\\\empty -lorem ipsum dolor\\\\\\empty +lorem ipsum dolor\\\\[0pt] +lorem ipsum dolor\\\\[0pt] \\vspace*{1em} -lorem ipsum dolor\\\\\\empty -lorem ipsum dolor\\\\\\empty +lorem ipsum dolor\\\\[0pt] +lorem ipsum dolor\\\\[0pt] \\end{verse}")))) (provide 'test-ox-latex) -- 2.35.1