Jacob <bishop.ja...@...> writes:

> 
> I have been experiencing the same problem. It seems to me that this IS a bug,
> and while what has been proposed (use \underline instead of \underbar) works,
> and is valuable input/information, it is a workaround to the bug, not a fix. 
> The bug still exists. At least, this is how I am reading the problem.
> 
> Any news on someone actually addressing the bug?

It's not exactly a bug in LyX, more like a quirk of LaTeX not (yet) addressed
by LyX.  See, for instance,
http://newsgroups.derkeiler.com/Archive/Comp/comp.text.tex/2009-11/msg00659.html.

That post led me to a LyX math-macro that defines a new command (I used 
\ubar but the name is arbitrary) that does the trick:

\begin_layout Standard
\begin_inset FormulaMacro
\renewcommand{\ubar}[1]{\underbar{\ensuremath{#1}}}
\end_inset

With this macro defined in the document body, you just type \ubar rather 
than \underbar in a math inset.  It seems to work with a variety of math
symbols, not just Greek letters.

I don't know any way to provide this in a module, though.  You can put the 
code in the preamble, but then LyX won't recognize it as a math macro.  So 
AFAIK your options are:

1.  insert the LaTeX code

\global\long\def\ubar#1{\underbar{\ensuremath{#1}}}

in the preamble (this can be done with a module), and in math insets type

\ubar\{

(which will generate an inset surrounded by braces), type your stuff in the
inset, and live with the fact that LyX does not display the underbar (but 
LaTeX will);

2.  create a document containing the macro definition in the body and save
it as a LyX template; or

3.  create a child document with the macro in it, and include the child in 
any document where you're going to feel an urge to use underbars.

This is bug #4565; I've amended the ticket to suggest the ensuremath fix.  
We'll see what happens.

/Paul



Reply via email to