避免在页面底部使用计数器

避免在页面底部使用计数器

我有以下计数器,但我不想让它成为页面底部的最后一项。如果计数器碰巧在那里,那么我希望它被移动到下一页,因为它的作用类似于其下方内容的标题。

在此处输入图片描述

平均能量损失

\documentclass{article}

\usepackage{parskip}

\usepackage{lipsum}

\usepackage{fontspec}

\usepackage[english,greek]{babel}

\usepackage{unicode-math}

\setmainfont
[
  UprightFont = GFSDidot.otf,
  BoldFont = GFSDidotBold.otf,
  ItalicFont = GFSDidotItalic.otf,
  BoldItalicFont = GFSDidotBoldItalic.otf,
]{GFSDidot.otf}

\setsansfont{GFSDidot.otf}

\setmathfont{latinmodern-math.otf}

\newcounter{Counter}

\newcommand{\Count}{\stepcounter{Counter}{\fbox{\large\textbf{\theCounter}}}}

\begin{document}

\lipsum[1-4]

Ut imperdiet,enim sed gravida sollicitudin, felis odio placerat quam, ac pulvinar elit purus eget enim. Nunc vitae tortor. Proin tempus nibh sit amet nisl. Vivamus quis tortor vitae risus porta vehicula. Ut imperdiet, enim sed gravida sollicitudin, felis odio placerat quam, ac pulvinar elit purus eget enim. Nunc vitae tortor. Proin tempus nibh sit amet nisl.

\Count

Ut imperdiet,enim sed gravida sollicitudin, felis odio placerat quam, ac pulvinar elit purus eget enim. Nunc vitae tortor. Proin tempus nibh sit amet nisl. Vivamus quis tortor vitae risus porta vehicula. Ut imperdiet, enim sed gravida sollicitudin, felis odio placerat quam, ac pulvinar elit purus eget enim. Nunc vitae tortor. Proin tempus nibh sit amet nisl.

\end{document}

答案1

您可以像其他标题防止分页符一样防止在下一个段落之前分页,方法是\par\nobreak\@afterheading

\documentclass{article}

\usepackage{parskip}

\usepackage{lipsum}

\usepackage{fontspec}

\usepackage[english,greek]{babel}

\usepackage{unicode-math}

\setmainfont
[
  %UprightFont = GFSDidot.otf,
  BoldFont = GFSDidotBold.otf,
  ItalicFont = GFSDidotItalic.otf,
  BoldItalicFont = GFSDidotBoldItalic.otf,
]{GFSDidot.otf}

\setsansfont{GFSDidot.otf}

\setmathfont{latinmodern-math.otf}

\newcounter{Counter}

\makeatletter
\newcommand{\Count}{\stepcounter{Counter}{\fbox{\large\textbf{\theCounter}}}\par\nobreak\@afterheading}
\makeatother

\begin{document}

\lipsum[1-4]

Ut imperdiet,enim sed gravida sollicitudin, felis odio placerat quam, ac pulvinar elit purus eget enim. Nunc vitae tortor. Proin tempus nibh sit amet nisl. Vivamus quis tortor vitae risus porta vehicula. Ut imperdiet, enim sed gravida sollicitudin, felis odio placerat quam, ac pulvinar elit purus eget enim. Nunc vitae tortor. Proin tempus nibh sit amet nisl.

\Count

Ut imperdiet,enim sed gravida sollicitudin, felis odio placerat quam, ac pulvinar elit purus eget enim. Nunc vitae tortor. Proin tempus nibh sit amet nisl. Vivamus quis tortor vitae risus porta vehicula. Ut imperdiet, enim sed gravida sollicitudin, felis odio placerat quam, ac pulvinar elit purus eget enim. Nunc vitae tortor. Proin tempus nibh sit amet nisl.

\end{document}

在此处输入图片描述

相关内容