1

The following defines my MWE:

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

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

\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}

enter image description here

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.

  • 1
    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
3

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}{%
    \parbox{\linewidth}{%
    \leavevmode\raisebox{-0.5ex}{\llap{\textbullet}}\!\hrulefill\\[-0.825ex]%
    \null\hfill\bfseries Total Points: \total{totalpoints}~~\rlap{\rule{0.4pt}{3ex}}%
    }%
}
  • 1
    And \leavevmode is redundant as \raisebox does it. Moreover \null\hfill should be \hspace*{\fill}. – egreg Feb 7 '16 at 0:31

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.