# LyX: text inside a LaTeX command not exported in XHTML

I have this LaTeX command in the preamble of my LyX document:

  \newcommand{\scenebreak}{%
\par
\vspace{\baselineskip}
\hfill
{\Large * * *}
\hfill
\vspace{\baselineskip}
\par}


I'm probably doing it wrong. In the PDF export, I get what I want: 3 large centred asterisks with a bit of vspace above and below, for a break between scenes.

In the XHTML export: nothing. Well, I think, an empty paragraph. In plain text export, only an extra blank line.

Can this be done, or do I have to type those asterisks myself every time?

I am using XHTML export as source for Calibre to make MOBI and EPUB files, so I will also vote up answers that satisfy that goal a better way.

• How do you export? File > Export > ? LyXHTML or HTML? If "HTML", then a follow-up question: what is the converter that you use defined as (specifically, the command) in Tools > Preferences > File Handling – scottkosty Dec 10 '14 at 20:55
• exported as LyXHTML – scav Dec 24 '14 at 19:48

The reason for this is that when using LyXHTML, LyX exports directly to HTML. It cannot export ERT to HTML because LyX does not convert LaTeX to HTML. For example, LyX knows what bold text is (if you use the LyX machinery and not ERT) and if the output is LaTeX it exports \textbf and if it's HTML it exports <b>. LyX has no idea what's in your ERT because that's custom LaTeX you're adding. LyX does not parse it. It just outputs it. But for LyXHTML it does not make sense to output it.

• this is a pity, but I am forced to accept it :( – scav Jan 5 '15 at 17:27
• Good point, scottkosty. If LyX has no idea what the ERT does, then exporting nothing at least will not mess up the HTML. Perhaps exporting the ERT as plain text would make sense, too, as an alternative behavior. – Rasmus Jan 21 '15 at 10:30
• @Rasmus True, that would make sense also. Or maybe we would want a different type of inset that does the same thing but is called differently so that both can be used simultaneously without messing up the other. – scottkosty Jan 21 '15 at 11:36

I think you might have found a bug in LyX, which you could consider reporting. I think it might be a bug as nothing I insert in Evil Red Text in LyX is exported by LyXHTML.

But you do not have to type the asterisks every time, for LyX has a very powerful shortcut mode you can use to avoid using ERT.

Go to Tools > Preferences > Editing > Shortcuts > New and insert as function

command-sequence paragraph-break; inset-insert vspace medskip; paragraph-params \align center; font-size larger; math-insert * * *; char-forward; inset-insert vspace medskip; paragraph-break; paragraph-params \align default


This will insert something very close to what you are seeking, though the asterisks are in math mode and the space medskip. I couldn't immediately figure out how to insert plain text asterisks, but for that, you can check Help > LyX Functions.

I hope this will suffice until the bug is fixed :)

• I don't think this is a LyX bug. Can you read my answer? I'd be interested in your thoughts. – scottkosty Dec 25 '14 at 15:41

I have a partial workaround, by inserting this into Document > Settings > Local Layout

Style Scenebreak

Font
Size Large
EndFont

Align center
LatexType paragraph

TopSep 1.5
BottomSep 1.5

NextNoIndent 1

HTMLStyle
div.scenebreak {
font-size: 150%;
text-align: center;
}
EndHTMLStyle

End


That gives me a "Scenebreak" style which I just type asterisks or whatever into. I need to do a little more work on it to make it come out properly in LaTeX but the XHTML output is adequate.

• Nice! Thanks for posting your workaround. Feel free to change the answer to yours, if you think that is the best answer. – scottkosty Jan 8 '15 at 20:52