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

User avatar
localghost
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.
\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¹
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

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