# How can I get rid of an Underfull \hbox message in my macro?

I can't find the reason for getting this message:

Underfull \hbox (badness 10000) in paragraph


This is my test case:

\newcommand{\ruler}{\noindent\rule[1ex]{\textwidth}{1pt}\\}
\newcommand{\rulercap}[1]{\ruler{\Large #1\hfill\\}\ruler}

\rulercap{test caption}

-

Your second call to \ruler ends with a linebreak, but the line is empty, which creates an underfull hbox. Do this instead:
\newcommand{\ruler}{\noindent\rule[1ex]{\textwidth}{1pt}}