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)?


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

\usepackage{showframe}      %% just to show the frame

%% 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

enter image description here

| improve this answer | |

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.