소스 검색

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
Max Nikulin 3 년 전
부모
커밋
892df429f4
2개의 변경된 파일9개의 추가작업 그리고 9개의 파일을 삭제
  1. 6 6
      lisp/ox-latex.el
  2. 3 3
      testing/lisp/test-org-table.el

+ 6 - 6
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} \\\\

+ 3 - 3
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