I would like to have a command \myTitle{Example} that would draw a rectangle starting after the text "Example" and going up to the right margin of the page.
This is how it would look like.
How can I do?
\leaders are your friend here.
\documentclass{article}
\usepackage{color}
\makeatother
\newcommand\myTitle[1]{%
\par\noindent{\large\bfseries\mbox{#1\ }\textcolor[gray]{.8}{\leaders\vrule height 1ex\hfill}\par}}
\begin{document}
\myTitle{Some Title}
\myTitle{Some Other Title}
\end{document}
raiseboxbut it is not working. – Colas Mar 14 '22 at 11:38\leaders\vrule height 2ex depth -1ex\hfill– David Carlisle Mar 14 '22 at 14:47\myTitle{Some Title with a p}. Thank you if you can help and sorry for the following up questions... – Colas Mar 14 '22 at 15:07depth 0ptMy original was aligned to the baseline unless the letters in the initial word had descenders (which they do not in this case). So the image in my answer has the rule on the baseline, the code in my previous comment lifts it off the baseline by 1ex – David Carlisle Mar 14 '22 at 15:12