LaTeX forum ⇒ Text FormattingNew Command for bold Text on colored Background

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
rawlins02
Posts: 20
Joined: Tue Oct 07, 2008 6:56 pm

New Command for bold Text on colored Background

Postby rawlins02 » Sun Dec 01, 2013 6:26 pm

I'm looking to define a command that will facilitate placement of bold text in a yellow background. Here is a start without the bold, that also fails to wrap. I've tried a number of options without much success.
  1. \def\comment{\colorbox{yellow}}{}

Suggestions please. Thanks.

Tags:

User avatar
Johannes_B
Site Moderator
Posts: 3582
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sun Dec 01, 2013 9:10 pm

In order to help you, we need more information. What is going to happen, if the text is longer than one line, or longer than one paragraph.

Can you supply those info in form of a compilable minimal example?

Have a look at mdframed or todonotes.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

rawlins02
Posts: 20
Joined: Tue Oct 07, 2008 6:56 pm

Postby rawlins02 » Mon Dec 02, 2013 4:06 am

Johannes_B wrote:In order to help you, we need more information. What is going to happen, if the text is longer than one line, or longer than one paragraph.

Can you supply those info in form of a compilable minimal example?


An example
  1. \documentclass{minimal}
  2. \usepackage{color,comment}
  3. \begin{document}
  4. \def\comment{\colorbox{yellow}}{}
  5.  
  6. In the compiled output text in curly brackets extends beyond the right margin
  7. \comment{ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZz}
  8.  
  9. \end{document}


Johannes_B wrote:Have a look at mdframed or todonotes.


I have explored both. Prefer a simple bold text in yellow background that wraps normally

User avatar
Johannes_B
Site Moderator
Posts: 3582
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Mon Dec 02, 2013 10:25 am

Well, than have a look at Cool Text Highlighting in LaTeX.

The simplest approach would be soul:
  1. \documentclass{article}
  2. \usepackage[width=5.05cm]{geometry}
  3. \usepackage{color,soul}
  4.  
  5. \begin{document}
  6. \noindent\hl{Highlighting} text feels good.
  7. You can draw attention of people to a \hl{word} or perhaps
  8. \hl{even a whole sentence that spans across multiple lines
  9. in such a way that hyphenation etc. are not affected.}
  10. \end{document}
Code taken from Caramdir.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 6 guests