## LaTeX forum ⇒ LyX ⇒ tex2lyx drops underscores and circumflex accents Topic is solved

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

### tex2lyx drops underscores and circumflex accents

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:

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.

Tags:

scottkosty
Site Moderator
Posts: 531
Joined: Sat Sep 01, 2012 6:38 am
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: 531
Joined: Sat Sep 01, 2012 6:38 am

Stefan Kottwitz
Posts: 9501
Joined: Mon Mar 10, 2008 9:44 pm
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 and \end. 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

dirkd
Posts: 2
Joined: Sun Dec 06, 2015 12:31 pm
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.