Warnings when using Listings in a RTL document
Udicoudco
udifoglle at gmail.com
Wed Mar 22 10:54:21 UTC 2023
On Tue, Mar 21, 2023 at 9:40 PM Scott Kostyshak <skostysh at lyx.org> wrote:
>
> On Tue, Mar 21, 2023 at 12:50:06PM +0100, Jürgen Spitzmüller wrote:
> > Am Dienstag, dem 21.03.2023 um 11:27 +0000 schrieb Udicoudco:
> > > Hello all,
> > >
> > > Attached a LyX file and its export to LaTeX code.
> > > When compiling with XeLaTeX the exported code
> > > I get the warning:
> > >
> > > \endL or \endR problem (0 missing, 1 extra) in paragraph at lines
> > > 26--27
> >
> > Interestingly, I don't get this warning with your example file. This is
> > with TeXLive 2023.
>
> I can reproduce on both TeXLive 2022 and TeXLive 2023. Note that the word "warning" is not used in the log file for this message. I get the same message as Udi except that the line numbers are different:
>
> \endL or \endR problem (0 missing, 1 extra) in paragraph at lines 28--29
>
> Scott
I've been reading e-TeX's and bidi's manuals, and done some experiments
To understand what is the meaning of this message, and why it is present.
It seems that the primitives \beginR and \beginL does not have to end with
\endR or \endL when used in horizontal mode (not restricted horizontal mode),
and if this is the case, e.g we started \beginR without ending it, all
subsequent text
will be typeset in a RTL paragraph, and the behaviour is restored to the default
at the start of the next paragraph.
If there is a \endL without \beginL at the paragraph level, we get a
message of the form
\endL or \endR problem (0 missing, 1 extra) in paragraph at lines....
inside \hbox the message will be a bit different.
The bidi package patches \everypar such that if the conditional \if at RTL is true
then \beginR is inserted at the start of the paragraph, otherwise
\beginL is inserted.
The command \LRE from the bidi package sets the conditional \if at RTL to
false. In addition,
this macro does not really have an argument, it basically expands to
something of the form
\LRE{Hello} -> {\beginL Hello}\endL (the \endL is outside of the group
intentionally)
Hence there will be no error if the "argument" contains several
paragraphs, even though \LRE
is not \long, but it is not meant to be used with such an "argument".
Now, when we do
\LRE{
\begin{lstlisting}
Hello
\end{lstlisting}
}
We basically have
\@RTLfalse\beginL{
\begin{lstlisting}
Hello
\end{lstlisting}
}\endL
Since the lstlisting start and end with \par, if we will discard
anything not important we will remain with
\@RTLfalse\beginL{
\par
Hello
\par
}\endL
Since all the primitives \beginL, \beginR, \endL, \endR are horizontal
commands, they start a paragraph.
So the line "}\endL" started a paragraph, outside of the scope where
\if at RTL is false, hence the paragrpah
started with \beginR, and so the \endL does not match any \beginL.
I think in the case of where forceLTR insets will have multiple
paragraphs, it is better to use
\begin{RTL}...\end{RTL}, which basically only issues \par and sets the
RTL related conditionals
to be false.
Regards,
Udi
> --
> lyx-devel mailing list
> lyx-devel at lists.lyx.org
> http://lists.lyx.org/mailman/listinfo/lyx-devel
More information about the lyx-devel
mailing list