1

I'm trying to make a paper form. I want to draw a horizontal line for people to write on. I want that line below the baseline. I found a TUGboat on making forms that defines an \xfill command that works fine in a paragraph, but I can't get it to work in a tabu environment. How can I use position something equivalent to \hrulefill below the baseline in a tabu environment?

MWE:

\documentclass{article}

% From https://www.tug.org/tugboat/tb24-2/tb77wilson.pdf
\newcommand*{\xfill}[1][0pt]{%
  \cleaders
  \hbox to 1pt{\hss
    \raisebox{#1}{\rule{1.2pt}{0.4pt}}%
    \hss}\hfill}

\usepackage{tabu}

\begin{document}

This works: \xfill[-0.5ex]

\begin{tabu}{@{}X@{}}
  Rule is too high: \hrulefill \\
  Rule is not visible: \xfill[-0.5ex] \\
\end{tabu}

\end{document}

Rendered:

Rendered MWE

I'm using MacTeX 2014, rendering with LuaLaTeX.

2

You could use the xhfill package which gives commands that extend \hrulefill allowing you to control the attributes (color, thickness, height/depth):

\documentclass{article}
\usepackage{xhfill}

% From https://www.tug.org/tugboat/tb24-2/tb77wilson.pdf
\newcommand*{\xfill}[1][0pt]{%
  \cleaders
  \hbox to 1pt{\hss
    \raisebox{#1}{\rule{1.2pt}{0.4pt}}%
    \hss}\hfill}

\usepackage{tabu}

\begin{document}

This works: \xfill[-0.5ex]

\begin{tabu}{@{}X@{}}
  Rule is too high: \hrulefill \\
  Rule is visible: \xrfill[-0.5ex]{0.4pt} \\
\end{tabu}

\end{document}

enter image description here

  • I'd like to point out that if you want to use \xrfill in a table cell by itself, you seem to need to \leavevmode first (e.g. \leavevmode\xrfill{0.4pt}). Without \leavevmode you get "Leaders not followed by proper glue." – dsedivec Aug 6 '14 at 5:17

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.