Graphics, Figures & TablesColoured bars under and below parts of words

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
tarasm
Posts: 2
Joined: Sat May 28, 2022 6:56 pm

Coloured bars under and below parts of words

Post by tarasm »

Hello,

I am trying to achieve the following in LaTeX:

Image

It's always some part of the word that has to be underlined, or overlined. the underlined/overlined length in characters always differs.

I'd like to type something like:

g\LOWERLINE{aa}tum y\LOWERLINE{a}jnaay\UPPERLINE{a}...

Can't figure out how to get this working.

Thanks in advance

Recommended reading 2024:

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

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

rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

Coloured bars under and below parts of words

Post by rais »

Here's an idea:

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{xcolor}
\newlength\mylinelength
\newlength\mylinethickness
\setlength\mylinethickness{2pt}
\newcommand*\LOWERLINE[2][cyan]{%
\settowidth\mylinelength{#2}%
\mbox{% this ensures the contents stay in one line
\makebox[0pt][l]{% this allows overprinting
\raisebox{-\mylinethickness}{% shift the rule below baseline
{\color{#1}\rule{\mylinelength}{\mylinethickness}}% the colored rule
}%
}%
#2%
}%
}%\LOWERLINE[color]{text}
\newcommand*\UPPERLINE[2][cyan]{%
\settowidth\mylinelength{#2}%
\mbox{% this ensures the contents stay in one line
\makebox[0pt][l]{% this allows overprinting
\raisebox{1.2ex}{% shift the rule above text
{\color{#1}\rule{\mylinelength}{\mylinethickness}}% the colored rule
}%
}%
#2%
}%
}%\UPPERLINE[color]{text}
\begin{document}
g\LOWERLINE{aa}tum y\LOWERLINE[red]{a}jnaay\UPPERLINE{a}...
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
May need some tweaking regarding rule positions, thickness, and color.

KR
Rainer
tarasm
Posts: 2
Joined: Sat May 28, 2022 6:56 pm

Coloured bars under and below parts of words

Post by tarasm »

Perfect! Thank you so much Rainer! And extra thanks for a prompt reply!

Best Regards,
T
Post Reply