以下定义了我的 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}
我担心的是
\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}}%
}
}
可能会在页面末尾中断,并在其中一页中给出一半的输出,在另一页中给出一半的输出?也就是说,如果定义为是,是break
自由的,那么即使在页面末尾,整个总点设计也会保持完整?请注意,该命令已经产生了所需的结果。
如果有更好的方法可以以更强大的方式实现相同的输出,我将不胜感激。我确实知道我可以在 TikZ 中复制输出。
答案1
%
它是一个 parbox,并且盒子永远不会破裂,但是为了避免虚假的空白,您在倒数第二行的末尾缺少一个。
\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}}%
}%
}