2018-05-04 13:27 GMT+02:00 Mario D <[email protected]>:

> Is there a simple way in lyx to change the background color of some text,
> maybe a paragraph?
>
> I have not been able to find a way to do this natively: the only way I
> could obtain it is by using the "soul" package, then inserting the latex
> code "\hl{" in ERT just before the the text to be highlighted and then a
> closing "}" at its end.
>

If you want a background colour to apply to certain paragraphs, on LyX it's
possible to define a paragraph style that apply the mdframe package. Go to
Document → Settings → Local format and add something like this (I'm using
2.3 here, if you're still on 2.2.x write "Format 60" instead)

Format 66


Style MyQuotation

Category MainText

Margin Static

LatexType Environment

LatexName myquotation

NextNoIndent 1

LeftMargin MMM

RightMargin MMM

ParIndent MM

ParSkip 0

ItemSep 0

TopSep 0.5

BottomSep 0.5

ParSep 0

Align Block

AlignPossible Block, Left, Right, Center

Preamble

\usepackage{mdframed}

\usepackage{xcolor}

\newenvironment{myquotation}

{\begin{mdframed}[

backgroundcolor=lightgray,

linecolor=lightgray

]\quotation}

{\endquotation\end{mdframed}}

EndPreamble

End

Validate, convert to the new format if necessary and now you'll have a new
paragraph environment called "MyQuotation" with some indents and light grey
background and borders.

[Got the idea from here

https://tex.stackexchange.com/questions/6851/create-new-paragraph-style-in-lyx#7471

I'd just converted the example to a Local Format]

Regards,
Ricardo






>
> Thanks
>

Reply via email to