LaTeX forum ⇒ GeneralHow to highlight a full line not just the text area

LaTeX specific issues not fitting into one of the other forums of this category.
Posts: 2
Joined: Wed Sep 24, 2008 1:34 pm

How to highlight a full line not just the text area

Postby SkyEye » Sat Sep 27, 2008 9:57 am

I'm quite new to LaTeX and LaTeX-Community has been a great help for the project report I'm working on. Thank you!

With my new found love on LaTeX I tried to do a different document which requires certain lines to be highlighted (up to the margin) with perhaps a different text color also. I've tried a few packages such as soul and xcolor for this purpose. I can get a text area highlighted, but it's not the whole line.

I'm thinking one of these could work
    Fill the rest of the line with spaces
    Use a table with one raw

I don't like the table way much, so I was thinking is there a better way to do this?

Any support on doing this using any method would be highly appreciated. I've attached a file which is what I'd like to achieve.
A line fully highlighted/color filled
line.png (3.55 KiB) Viewed 5563 times

User avatar
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Sat Sep 27, 2008 10:33 am

Take this as an example. Pay attention to the included packages.
  1. \documentclass[11pt,a4paper]{article}
  2. \usepackage[T1]{fontenc}
  3. \usepackage[latin1]{inputenc}
  4. \usepackage[english]{babel}
  5. \usepackage[centering,includeheadfoot,margin=2cm]{geometry}
  6. \usepackage{xcolor}
  7. \usepackage{calc,blindtext}
  9. \setlength{\parindent}{0pt}
  11. \begin{document}
  12. \colorbox{blue}{\makebox[\textwidth-2\fboxsep][l]{\bfseries\color{white} Academic Achievements}}
  14. \medskip
  15. \blindtext
  16. \end{document}

If you want to highlight headings in this way, you may take a look at the titlesec package. Packages and their documentations are available on CTAN.

Best regards and welcome to the board
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

Posts: 2
Joined: Wed Sep 24, 2008 1:34 pm

Postby SkyEye » Sat Sep 27, 2008 11:16 am

This is what I was looking for. Thank you!

I've already used the packages geometry and xcolor. So I needed to include the calc and, I didn't know about \textwidth and \fboxsep either. :)

It's great you have a friendly forum like this, especially for new LaTeX users like me. Thanks again.

Return to “General”

Who is online

Users browsing this forum: No registered users and 5 guests