LyXtex2lyx drops underscores and circumflex accents

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
dirkd
Posts: 2
Joined: Sun Dec 06, 2015 12:31 pm

tex2lyx drops underscores and circumflex accents

Post by dirkd »

I tried to import an old tex-file into LyX. Generally, the import went well but all occurences of underscores (_) and circumflex accents (^) were simply removed. And there are a lot of them. When LyX was able to determine that math-mode was active it interpreted the accents well (as sub- and superscripts), but when it thought it was reading plain text, it just dropped them.

Here's a short excerpt as an example:

Code: Select all

Twee {\trm termen} $a_m$ en $a_n$ $(m>n)$ in een MR liggen $m-n$ posities uit elkaar. Hieruit volgt dat
\beq a_m=a_n\cdot r^{m-n}. \eeq
The a_m symbol between dollar-tags is imported correctly (with a subscript), the a_m between \beq and \eeq tags is imported simply as 'am', while I would want it to be imported literally as 'a_m'.

Any help would be appreciated.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Re: tex2lyx drops underscores and circumflex accents

Post by scottkosty »

I would suggest you make a minimal example and file a bug report at http://www.lyx.org/trac. In the bug report, please select the component "tex2lyx".
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Re: tex2lyx drops underscores and circumflex accents

Post by scottkosty »

User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

tex2lyx drops underscores and circumflex accents

Post by Stefan Kottwitz »

Hi Dirk,

welcome to the forum!

I assume \beq and \eeq are tags defined by you. When I would naively look at that code, I would see that a_m=a_n\cdot r^{m-n}. is not in math mode. That's why the underscore and the circumflex would be illegal there, thus they are dropped.

A clever assumption would be that you defined \beq and \eeq as abbreviation for math mode, such as for \begin{equation} and \end\begin{equation}. I guess tex2lyx does not see that. This shortcut syntax is bad anyway, it hides the original meaning and changes an environment syntax to pairs of commands.

An easy way would be automatic search & replace of those shortcuts via any editor.

Stefan
LaTeX.org admin
dirkd
Posts: 2
Joined: Sun Dec 06, 2015 12:31 pm

Re: tex2lyx drops underscores and circumflex accents

Post by dirkd »

Hi Stefan,

thanks for your help. In the meantime I thought about your search-and-replace solution myself, and since there were only four troublesome definitions that tex2lyx didn't like, I quickly had a working lyx-version of my tex-file.

I am convinced now that this behaviour of tex2lyx is fully by design, since an underscore in plain text seems to be handled completely different from an underscore in math-mode by LyX. Fixing the underscores AFTER importing in LyX with search-and-replace seems impossible.

So consider this question as solved. Thanks again, I learned yet a bit more about LyX.
Post Reply