Juan Manuel Macías <maciasch...@posteo.net> writes: > 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.
I tried to add the safe version of page break everywhere where there is a risk of a page break followed by square brackets. The key point: A valid Org file must be exported to a valid LaTeX file. If you know a selective solution, patches are welcome. (I am also CCing Daniel). I see no issue with defcustom in general, but can you explain what practical problems it is going to solve? I am not talking about aesthetics of the exported LaTeX. > 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} Won't it make it impossible to use @@latex:\\@@ @@latex:[1em]@@ deliberately? Note that we may also replace \\\empty with a single custom command. It will look a bit cleaner. Not sure if it is any different from your approach. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>