I have sentences in which characters have been "marked" by some people and not by others. I'd like to present the markings simultaneously. Stacked colored underlining (in which a line represents each person's marks) seems like the best solution. However, I'm struggling to make that happen. How can I present multiple markings simultaneously?
Goal
Code That Fails
Because }
closes the most recent {
, the following code only works for a subset of examples (it fails on the goal example):
\documentclass{article}
\usepackage{xcolor}
\newcommand{\rul}[1]{\textcolor{red}{\underline{\textcolor{black}{#1}}}}
\newcommand{\bul}[1]{\textcolor{blue}{\underline{\textcolor{black}{#1}}}}
\begin{document}
\rul{sample \bul{with blue embedded} and continuing red}
\end{document}
I've experimented a bit with \lefteqn
and \phantom
. Using these commands resolves the bracket mismatching, but it has two other problems: it's text in math mode, and there isn't a vertical gap between the two underlining colors:
\[\lefteqn{\rul{\phantom{overlapping high}}}overlapping \bul{highlighting}\]
Other Considerations
I need to make many pages of this sort of text. For readability, the solution should have the following properties:
- Underlining automatically wraps across lines.
- Underlining of a single color stays on the same horizontal level throughout the document (e.g., blue is always n units below baseline).
- Scales up to ~10 stacked underlines in a document section.
Because of the amount of this text, a readable/maintainable solution would be aces.
baselinestretch
and then use a raphics program (e.g., GIMP) to manually draw these lines. It will surely be quicker to do it this way, and surely much easier to maintain. Not as 'fun' a solution, probably, but easier to do!\underbar
looked like exactly what I was after, but I spent some time playing with ConTeXt's online pdf producer and I couldn't replicate the "overlapping highlighting" example. How did you do it?