LyXNative way to highlight text

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
rahul24
Posts: 4
Joined: Thu Sep 20, 2012 10:36 am

Native way to highlight text

Post by rahul24 »

I want to highlight small portions of text (like 2-3 key words or a perhaps sentence (inline in a paragraph or standard environment)) in Lyx so that the highlight is visible on-screen. For the latex output I simply use \colorbox{}{} but this only appears on paper/pdf. Is there a native way to do this Lyx so that I can see the highlighted portion on-screen and not have to use an ERT for latex output.

Any answers????

Thanks in advance,
Rahul
Last edited by cgnieder on Mon Oct 01, 2012 10:25 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Native way to highlight text

Post by scottkosty »

rahul24 wrote:I want to highlight small portions of text (like 2-3 key words or a perhaps sentence (inline in a paragraph or standard environment)) in Lyx so that the highlight is visible on-screen. For the latex output I simply use \colorbox{}{} but this only appears on paper/pdf. Is there a native way to do this Lyx so that I can see the highlighted portion on-screen and not have to use an ERT for latex output.

Any answers????
You're half-way there already with knowing how to use \colorbox. I don't know if you consider this solution "native" to LyX (LaTeX is really doing the rendering) but it should do what you want.

Enter your \colorbox command using ERT, then, highlight the ERT box and go to Insert > Preview
You should see a black box around your red ERT box.

Then go to Tools > Preferences > Look & Feel > Display and set "Instant Preview" to "On". You might have to click inside the black box and then out again because you're just enabling it.
rahul24
Posts: 4
Joined: Thu Sep 20, 2012 10:36 am

Re: Native way to highlight text

Post by rahul24 »

Thanks for the solution. Its a bit convoluted but does the job!!!!!
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Native way to highlight text

Post by scottkosty »

rahul24 wrote:Thanks for the solution. Its a bit convoluted but does the job!!!!!
Glad to hear that it's at least a bearable solution!
poliorcetes
Posts: 6
Joined: Tue Aug 12, 2014 12:10 pm

Native way to highlight text

Post by poliorcetes »

Thanks for this amazing Preview notice.

I am a long-term user of LyX. I was so used to the old interface of versions 1.x than I didn't pay attention of this wonderful real-time preview. Great!

Now, if you people want to highlight text, \colorbox is not a great solution since it interferes greatly with text boxes and above all line heights. There is a better solution:

In the preamble, use:
\usepackage{soul}

and inside text body, if you want to highlight properly, just do this

\hl{highlighted text}
Post Reply