On Sun, Feb 24, 2013 at 1:43 PM, Paul A. Rubin <ru...@msu.edu> wrote:
> I would use a math macro (section 22.2 of Help > Math). Create the macro
> somewhere near the front of the document (Insert > Math > Macro inside a math
> inset). If the symbol you are bolding is always 'x', define a macro with an 
> easy
> to type name (say \XX or \bX) that has no arguments and inserts the LaTeX code
> including the 'x'. If you have a few symbols, maybe do one such macro for 
> each.
> If you have a lot of symbols, create a macro (say \bv) that takes an argument
> and then hit every vector over the head with it (replace 'x' with '\bv{x}' 
> etc.).
>

Thanks. This is what I was trying before.  Alls well that ends well.
Your comment made me try harder to wade through  the documentation.
This is difficult to describe.

In case another user needs help with LyX macros, here is what I found out.

I hit the "\foo :=" button to create my macro.

That opens a box with 3 parts. There's the macro definition, and two
boxes that say TeX and LyX.

When I start, I see like this
                            _    _
\newmacroname:  |_|  |_|
                          TeX LyX

First, rename the thing on the left. It provides the starting
backslash, Don't add another one. Just replace the letters
"newmacroname" with "vb" or something nice.

Caution: the macroname must also include the argument definition.  You
must not simply type "vb{#1}", even if that is what you really want.
If you type {#1}, LyX will show that in big blue letters. It is trying
to make "#1" part of the name, rather than an argument.

LyX GUI has a tool to define the argument.  When you open the macro
editor, LyX pops up a menu similar to the math editor. Use that! In
there I choose the two green braces like {} with a popup "append
argument". Hit that button, and the macro editor inserts {#1} at the
end of your macro name and it also plops a #1 into the "TeX" box.

The documentation says, "The wanted formula is inserted in the first
blue box."  How it gets in there is the big mystery to me.

After I did the "append argument" button, the last two boxes look like this:
 _      _
|#1|  |_|
TeX LyX

It is a bit tricky to put the desired macros into the box on the left.
You can't just type them. My first try was to just type;

\bm{\mathrm{#1}}

Epic fail. Just as I could not type #1 in my macro name, I can't type
it here. Typing #1 leads to a big blue #1, where LyX thinks I mean the
math symbols are #1, not that I mean the argument placeholder.

So I have to go back and figure a way to enter my \bm{\mathrm{}} so
that wraps itself around the #1 that the append argument button
inserted for me.

I've not found a perfectly safe way to do that.  I highlight the #1 in
the little box, then what?

When I type in \bm, that "disappears".  Then I type \mathrm, it
disappears.  Which to type first? My first guess was that I'd type
"\mathrm" as the inner argument, and then \bm.
That's backwards, It turns out.

I get a different result if I write the macro as \mathrm{\bm{}} or
\bm{\mathrm{}}, so getting the macro correct is a hit-and-miss
proposition.  With View Source turned on, I can see that LyX is
creating markup for my macro like this:

\global\long\def\vb#1{\mathrm{\bm{#1}}}

That has \mathrm and \bm backwards. After some fiddling, the view
source shows me this:

\global\long\def\vb#1{\bm{\mathrm{#1}}}

And then my \vb math macro seems to work as intended.

What goes in the little box called "LyX"? I don't know.

Maybe section 22.2 of Math begins with a too-difficult example.

pj


> Paul
>



-- 
Paul E. Johnson
Professor, Political Science      Assoc. Director
1541 Lilac Lane, Room 504      Center for Research Methods
University of Kansas                 University of Kansas
http://pj.freefaculty.org               http://quant.ku.edu

Reply via email to