6

Is there a command or package which would allow me to draw a line in the largest available space in the way that \hfill fills up the remaining space in a line?

i.e., a command to draw a line from the end of the text, wherever it happens to fall, to the right edge of the textwidth (leaving space for any additional text indented to be at the end of the line)?

10

You can use ordinary \hrulefill. There is also \dotfill for dots. For advanced control xhfill may be used.

\documentclass{article}
\usepackage{showframe}      %% just to show the frame
\usepackage{xhfill}
\setlength{\parindent}{0pt}
\begin{document}

%% Usage
%% \xhrulefill{<color>}{<height>}
%% \xrfill[raise]{ruleheight}[color]
%% \xhrectanglefill{<height>}{<linewidth>}
%% \xhrectanglefill{1cm}{1pt}

First \verb|\xrfill|\xrfill{1pt}

This is \verb|\xrfill|\xrfill[0pt]{3pt}[blue]

A take with \verb|\xhrulefill|\xhrulefill{cyan}{1cm}

With \verb|\xhrectanglefill|\xhrectanglefill{0.5cm}{1pt}

%% Ordinary \hrulefill

With \verb|Ordinary \hrulefill|\hrulefill

With \verb|Ordinary \dotfill|\dotfill
\end{document}​

enter image description here

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.