emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Line breaks and brackets in LaTeX export (was: [bug] `org-latex-line-bre


From: Juan Manuel Macías
Subject: Line breaks and brackets in LaTeX export (was: [bug] `org-latex-line-break-safe' breaks the export of verse blocks to LaTeX)
Date: Sun, 16 Oct 2022 17:14:40 +0000

Max Nikulin writes:

> In my opinion Org has to apply a general solution merely because a table 
> may be result of evaluation of an org-babel code block. I may be wrong, 
> but I suspect that some users do not care what is the intermediate 
> format when they need a PDF file.
>
>> And finally, I think that applying a general solution to this problem is
>> something that should be done(IMHO) in LaTeX and not in Org,
>
> Org has a bit more information concerning context of square brackets. 
> They may be just text of a table cell or contents of an export snippet. 
> In a LaTeX file they are just square brackets and there is no way to 
> distinguish them.
>
> I believe, it is a design flaw in LaTeX that the \\ command does not 
> have a counterpart with no optional * and [] arguments. For humans \\ is 
> enough, but it is fragile when LaTeX is used as an intermediate export 
> format. A part of the problem is that all 3rd party packages should be 
> adapted for the robust \\ sibling. Likely it may be solved by additional 
> pass in the exporter code but it will significantly increase its 
> complexity. I have no idea what is appropriate place to discuss such 
> issue with LaTeX developers.

The solution of adding \relax or \empty is a good one. The problem is
when it is applied massively and indiscriminately, bearing in mind that
it is to prevent a problem that is, frankly, very rare. \empty is
unlikely to have any side effects, but still, I don't like Org making
these decisions for me and adding LaTeX code that I didn't ask for, in
form or quantity. Isn't it possible to be more selective, like Pandoc
does (I think), and add what needs to be added only when the problem is
present? I don't know if the Pandoc thing has already been mentioned in
past discussions, because these days I haven't been paying attention to
the list.

In any case, I would prefer: a) a selective solution; and if a) is not
possible, at least b) a defcustom.

This is an example I came up with of how it could be fixed selectively
in LaTeX (big, big caveat: it's just a proof of concept and likely to
produce errors in other contexts. I think if a LaTeX package to fix this
isn't already out, it is either because the problem is very rare and the
solution for particular cases is known, or because there are drawbacks
inherent to LaTeX that I can't figure out right now):

\makeatletter

\def\my@protectlbrack{
  \@ifnextchar{[}{\relax}{}
  \@ifnextchar{*}{\relax}{}
}

\let\old@break\\
\def\\{%
  \old@break\my@protectlbrack}

%% for tables

\let\old@tabularcr\@tabularcr
\def\@tabularcr{%
  \old@tabularcr\my@protectlbrack}

% for use the old commands

\newcommand\oldbreak{\old@break}
\newcommand\oldbreakt{\old@tabularcr}

\makeatother

\begin{document}

lorem\\
[ipsum]

lorem\\
*ipsum

\begin{tabular}{cccc}
a & a & a & a \\
[a] & a & a & a \\
*a & a & a & a \\
\end{tabular}


\end{document}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]