# Re: text styles

tedc wrote:

I'm thinking of using LyX to write the 2nd edition of a book. The 1st edition
was done with OpenOffice, but production was a nightmare because OO didn't
fit with the publisher's workflow. The publisher had the whole thing
retyped, which introduced countless errors and generally broke formatting--a
major concern in this book which contains lots of source code, mathematical

symbols, chemical reaction notation etc..
The publisher will accept LaTeX, which gives LyX a tremendous potential
advantage. Exporting from OO to tex does damage some of the formatting, but
it does preserve many essentials such as index tags. The resulting files
import into LyX, seem to work more or less with the publisher's cls file,
and it looks like I can repair the broken formatting with LyX.

I do have one question, though. The OO file used "text styles" to specify
the formatting of inline source code, names of GUI tools, and chapter
crossreferences. In LyX these show up as ERT, like the boldfaced bit here:
\textstyleInlinecode{for i=0,n-1}
When I click on View DVI, these generate "Undefined control sequence"
errors.

I could, of course, use sed or awk to replace these with LyX markup that
would force the "correct" typeface (in this case, the typewriter family),
but I'd rather leave the markup unchanged, and have LyX or LaTeX figure out
what to do.

So my question is: how do I tell LyX or LaTeX that
\textstyleInlinecode{for i=0,n-1}
means to render
for i=0,n-1
with a specified typeface? or at least as "typewriter"?


There are going to be a lot of ways to do this. But I think all of them will involve using sed or whatever to replace this kind of command with something more sensible, preferably, a LyX character style. I think the way to go here would be to do the import into LyX and then write a script to convert things that will look more or less like this:

\begin_inset ERT
\begin_layout Plain Layout

\textstyleInlinecode{for i=0,n-1}
\end_layout
\end_inset

with something more like this:

\begin_layout Flex CharStyle:Code
status closed

\begin_layout Plain Layout

for i=0,n=1
\end_layout
\end_inset

This is easy, eventually, though fiddly.


In this case, you can use the Logical Markup module, which already defines the Code charstyle. In other cases, you may want to roll your own.

rh