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.
Post Reply
SkyEye
Posts: 2
Joined: Wed Sep 24, 2008 1:34 pm

How to highlight a full line not just the text area

Post by SkyEye »

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.
Attachments
A line fully highlighted/color filled
A line fully highlighted/color filled
line.png (3.55 KiB) Viewed 10498 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to highlight a full line not just the text area

Post by localghost »

Take this as an example. Pay attention to the included packages.

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage[centering,includeheadfoot,margin=2cm]{geometry}
\usepackage{xcolor}
\usepackage{calc,blindtext}

\setlength{\parindent}{0pt}

\begin{document}
  \colorbox{blue}{\makebox[\textwidth-2\fboxsep][l]{\bfseries\color{white} Academic Achievements}}

  \medskip
  \blindtext
\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
Thorsten¹
SkyEye
Posts: 2
Joined: Wed Sep 24, 2008 1:34 pm

Re: How to highlight a full line not just the text area

Post by SkyEye »

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.
Post Reply