1

I'm trying to recreate the typewriter look.

How to make \underline{sometext} work like SETEX-style section marker?

The intended use is with monospaced/typewriter fonts for lines with plenty of space beneath them (like section headings).

Illustration of desired effect below.

Underline text SETEX style

1
3

For example using \halign and \leaders primitives:

\def\underlined#1{\vtop{\tt\halign{##\cr#1\cr\leaders\hbox{=}\hfill\cr}}}

Text: \underlined{Odwolanie upowaznienia}

\bye
4
  • Neat solution with \leaders – DG' Jan 15 at 16:51
  • How do you adjust the distance of the underlining from the underlined text? – Marek Kowalczyk Jan 18 at 23:14
  • @MarekKowalczyk Using \noalign{\kern-1pt} (-1pt just for example) inserted between second \cr and \leaders in the macro. – wipet Jan 19 at 13:19
  • This works: \def\underlined#1{\vtop{\halign{##\cr#1\cr\noalign{\kern-6pt}\leaders\hbox{=}\hfill\cr}}} – Marek Kowalczyk Jan 21 at 13:47
1

The real typewriter look can be achieved by setting a number of = below the title. Here is an example with \section:

\documentclass{article}

\usepackage{xstring}
\usepackage{multido}
\usepackage[explicit]{titlesec}
\usepackage[default]{sourcecodepro}

\newcommand\setex[1]
  {#1 \\ \StrLen{#1}[\len]\multido{}{\len}{=}}

\titleformat{\section}
  {\normalfont\filcenter}{}{0pt}{\setex{#1}}

\begin{document}

\section{Test}

Lorem ipsum...

\end{document}

enter image description here

This will not work for really long section titles.

3
  • How do you adjust the distance of the underlining from the underlined text? – Marek Kowalczyk Jan 18 at 23:14
  • It's just a simple line of text, you can try adjusting the baseline or something like that – DG' Jan 19 at 8:57
  • 1
    This works: \newcommand\setex[1]{#1 \\ \StrLen{#1}[\len]\kern-4pt\multido{}{\len}{=}} – Marek Kowalczyk Jan 21 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.