Re: Background color in a paragraph

2018-05-05 Thread Ricardo Berlasso
2018-05-04 13:27 GMT+02:00 Mario D :

> 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
>


Re: Background color in a paragraph

2018-05-05 Thread Mario D
I tried box with colored background but they don't work properly if the
text is more than one line long as in this case the line is not wrapped
around.
It is possible to get this, but it is not straightforward.

Given that I do not use the feature quite often, the hack I proposed is
fine for me.

Yet, I think it is a feature that would be nice to have natively.

2018-05-04 15:25 GMT+02:00 Bernt Lie <bernt@usn.no>:

> A couple of years ago, I tried to use Insert/Box/... with colored
> background. I wanted to have greyed background for Examples. Didn’t work
> well... if I included floating objects (Figures, Tables, etc.), the preview
> got messed up. Maybe it works better with floats in ordinary paragraphs – I
> haven’t tested that.
>
>
>
> But if you have simple paragraphs, that might work.
>
>
>
> -B
>
>
>
> *From:* lyx-users@lists.lyx.org <lyx-users@lists.lyx.org> *On Behalf Of *Mario
> D
> *Sent:* Friday, May 4, 2018 13:27
> *To:* lyx-users <lyx-users@lists.lyx.org>
> *Subject:* Background color in a paragraph
>
>
>
> 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.
>
> Thanks
>


RE: Background color in a paragraph

2018-05-04 Thread Bernt Lie
A couple of years ago, I tried to use Insert/Box/... with colored background. I 
wanted to have greyed background for Examples. Didn’t work well... if I 
included floating objects (Figures, Tables, etc.), the preview got messed up. 
Maybe it works better with floats in ordinary paragraphs – I haven’t tested 
that.

But if you have simple paragraphs, that might work.

-B

From: lyx-users@lists.lyx.org <lyx-users@lists.lyx.org> On Behalf Of Mario D
Sent: Friday, May 4, 2018 13:27
To: lyx-users <lyx-users@lists.lyx.org>
Subject: Background color in a paragraph

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.
Thanks


Background color in a paragraph

2018-05-04 Thread Mario D
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.

Thanks