TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a command definition in my LaTeX preamble:


But the usage of this command appears as an ERT e.g. \code{select}. I would like this to appear as select that is, italics. How to do this?

share|improve this question
what is an ERT? And exactly what do you want to do? Will changing \texttt with \textit solve your problem? – Juan A. Navarro Oct 31 '10 at 8:12
@Juan: ERT is Lyxspeak for Evil Red Text, meaning Lyx's pretensions to be a graphical editor are compromised. – Charles Stewart Oct 31 '10 at 9:54
Hi, is there some progress in this question? I would like to be able to do the same but for textcolors. – Santi Feb 24 '15 at 19:20

You need to tell Lyx how it is to mark up the command, by changing the layout you use, or, probably the right thing, defining a module.

Rob Oakes has written a weblog post, Customizing Lyx: An Introduction to Modules. His explanation make it look quite simple to do, although I've never tried.

share|improve this answer
I knew about Rob Oakes' post but it is way too complicated for my simple task. – phaedrus Nov 7 '10 at 12:39

I was able to extract my answer from Rob's another article here: Close your lyx file from within lyx editor. Put the following near the top of your lyx file after \end_modules using a text editor. Reopen the lyx file using the lyx editor. Then you can customize a part of your text by: Select text > Right Click > Text Styles > Charstyle:code.

    Format 7
      InsetLayout    CharStyle:Code
      LyxType               charstyle
      LabelString           code
      LatexType             command
      LatexName             code
        Family              Sans
        Color               Green

To use the same layout for a different document, use File > New from Template.

share|improve this answer
Hi, I know is some sort of old question. But I don't get it, I can't find this \end_modules in my document. And isn't there by now a simpler answer. I just want that if someone defines \newcommand{\comment}[1]{\textcolor{red}{#1}}, in the latex file, I am able to see the color in my Lyx file. It cannot be that difficult to just replace this command as it is done with the math macros. – Santi Feb 24 '15 at 19:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.