# Improve command definition to avoid possible break

The following defines my MWE:

\documentclass{article}
\usepackage{amsmath}
\usepackage{totcount}
\newcounter{totalpoints}
\regtotcounter{totalpoints}

\newcommand{\shcpoint}[1]{%
\ifnum#1<2
(\emph{#1 point})\hphantom{\em s}%
\else
(\emph{#1 points})%
}

\newcommand{\totalpoints}{%
\parbox{\linewidth}{%
\leavevmode\raisebox{-0.5ex}{\llap{\textbullet}}\!\hrulefill\\[-0.825ex]%
\null\hfill\bfseries Total Points: \total{totalpoints}~~\rlap{\rule{0.4pt}{3ex}}%
}
}
\begin{document}
This questionary has a total of \total{totalpoints}~points.
\begin{enumerate}
\item \shcpoint{1} Easy question
\item \shcpoint{2} Some random question
\item \shcpoint{3} Other question
\end{enumerate}
%------------------------------------------------------------------------------------
\totalpoints
%------------------------------------------------------------------------------------
\end{document}


What I am concerned about is if the command

\newcommand{\totalpoints}{%
\parbox{\linewidth}{%
\leavevmode\raisebox{-0.5ex}{\llap{\textbullet}}\!\hrulefill\\[-0.825ex]%
\null\hfill\bfseries Total Points: \total{totalpoints}~~\rlap{\rule{0.4pt}{3ex}}%
}
}


will break maybe at the ends of pages and give half of the output in one and half in the other? That is, if defined as is, is break free so that the whole total points design stays intact even when at the end of a page? Note as it is, the command already yields the desired result.

If there are better ways of achieving the same output but in more robust manner, I would appreciate insights. I know for a fact that I can replicate the output in TikZ.

• it's a parbox and boxes never break (you are missing one % at the end of the penultimate line though) – David Carlisle Nov 7 '13 at 23:48
• @DavidCarlisle Other than that, is the command properly defined? Are there any other suggestions to make it better or other flavors to achieve the same result? Appreciate the input. :-) – azetina Nov 7 '13 at 23:51
• @DavidCarlisle wanna make that an answer, or do you want to ping egreg for the EOL? :-) – Johannes_B May 12 '15 at 19:40
• @DavidCarlisle Would you make an answer? – egreg Feb 6 '16 at 23:12

It's a parbox and boxes never break however to avoid spurious white space you are missing one % at the end of the penultimate line.
\newcommand{\totalpoints}{%

• And \leavevmode is redundant as \raisebox does it. Moreover \null\hfill should be \hspace*{\fill}. – egreg Feb 7 '16 at 0:31