Re: LyX2.4.4 Problem with textquoteright when used as an apostrophe in a box containing a Listing
Gerhard Gsänger via lyx-users <[email protected]>
| Newsgroups | gmane.editors.lyx.general |
|---|---|
| Message-ID | <[email protected]> |
> Am 12.12.2025 um 20:06 schrieb Gerhard Gsänger via lyx-users <[email protected]>: > > Hi > I’m using LyX2.4.4 on my Macbook M2 with Tahoe 26.1. > > Attached is a small LyX example, demonstration the issue. > > When I copy the following sentence from a website and paste it into a LyX documents the apostrophe (textquoteright) used in „doesn’t“ is causing an error when viewing the doc as PDF (LuaTex): > > CTAD doesn’t (currently) work with function parameters. > > The details are explained in the attached LyX file. The error happens only when this textquoteright is used inside a box containing the text plus a Listing box. > What can I improve? > > > Gerd > > > > <textquoteright.lyx>-- > lyx-users mailing list > [email protected] > https://lists.lyx.org/mailman/listinfo/lyx-users Update: I would like to add a better description, some assumptions regarding cause und a proposed workaround. Subject: LuaLaTeX crashes on typographic quotes inside boxes containing listings Description: In LyX 2.4.4, when a document contains boxes (e.g., Simple Frame) that include both ordinary text with typographic quotation marks (‘ U+2018, ’ U+2019, “ U+201C, ” U+201D) and a listings environment, compiling with LuaLaTeX produces errors such as: Undefined control sequence. doesn\T 1\textquoteright t ... • The error does not occur in boxes that contain only text, nor in normal paragraphs. • LyX editor displays the typographic quotes correctly. • PDF output may appear correct depending on font ligatures, but LuaLaTeX fails during compilation when the listing is present in the same box as typographic quotes. Not a LyX-specific issue: • A plain LaTeX file containing the same box + listing + typographic quotes exhibits the exact same LuaLaTeX error. • Compiling the same file with standard pdfLaTeX produces no error. • This confirms that the issue is due to LuaLaTeX’s handling of Unicode typographic quotes in fragile environments, not LyX itself. Cause: • LuaLaTeX attempts to expand Unicode typographic quotes to LaTeX commands (e.g., \textquoteright) inside fragile box/listing combinations, which is not allowed, causing compilation errors. Workarounds: 1. Replace typographic quotes with ASCII ' or " before pasting into boxes. 2. Or, add the following macro to the LaTeX preamble to convert all typographic quotes to ASCII at compile time: \AtBeginDocument{% \catcode`’=\active \protected\def’{'}% \catcode`‘=\active \protected\def‘{'}% \catcode`“=\active \protected\def“{"}% \catcode`”=\active \protected\def”{"}% } • Ensures LuaLaTeX compiles successfully while retaining typographic appearance in the PDF. Steps to reproduce: 1. Create a LyX 2.4.4 document (or plain LaTeX file). 2. Insert a Simple Frame box (or minipage/tcolorbox). 3. Inside the box, add: • A text string containing typographic quotes. • A listings environment with code. 4. Compile using LuaLaTeX. 5. Observe the “Undefined control sequence” error related to \textquoteright. 6. Compile with standard pdfLaTeX: no error occurs. -- lyx-users mailing list [email protected] https://lists.lyx.org/mailman/listinfo/lyx-users