# Lyx Local Layout, markup for R code in documents

While preparing book manuscript, I found the need to mark code of various styles, R functions, variables, and I needed this to be flexible and fixable later when publisher changed mind on style. Here’s the secret recipe.

In Lyx Document Settings

1. In modules, turn on the module “Logical Markup”.

Test that out, see what they intend. You can highlight things and with a right click choose a markup style.

2. The existing markup may not suit your needs, but there is a customization route. In Document Settings, there is a thing “Local Layout”. In there, put markup that will work with the module. Here is mine

```Format 7
InsetLayout CharStyle:Rinput
LyxType               charstyle
LabelString           Rinput
LatexType             command
LatexName             Rinput
Font
Family             Typewriter
EndFont
Preamble
\newcommand*{\Rinput}[1]{{\ttfamily #1}}
EndPreamble
End

InsetLayout CharStyle:Rfunction
LyxType               charstyle
LabelString           Rfunction
LatexType             command
LatexName             Rfunction
Font
Family             Typewriter
EndFont
Preamble
\newcommand*{\Rfunction}[1]{{\ttfamily #1}}
EndPreamble
End

InsetLayout CharStyle:Routput
LyxType               charstyle
LabelString           Routput
LatexType             command
LatexName             Routput
Font
Family             Typewriter
EndFont
Preamble
\newcommand*{\Routput}[1]{{\ttfamily #1}}
EndPreamble
End
```

After that, right click magic!

Now also working on how to automatic the markup of matrices in latex. Have done it in one document, but will come back here to write.