\allowdisplaybreaks 和 \frontmatter

\allowdisplaybreaks 和 \frontmatter

基于此讨论,

仅允许从偶数页到奇数页的显示中断

我使用宏

\makeatletter
\everymath{%
  \ifodd\thepage\allowdisplaybreaks[0]%
    \else \allowdisplaybreaks[4]%
  \fi
}
\makeatother

允许在公式中仅从偶数页到奇数页分页。当我\frontmatter在文件开头使用该命令时,出现以下编译错误消息:

! Missing number, treated as zero.
<to be read again> 
                   i
l.25 \end{align*}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

此消息是什么原因造成的?我该如何解决这个问题?

NB1:我有此错误信息,但文件编译良好......

NB2:此错误信息是由命令引起的...即,如果命令不存在,\frontmatter则不会出现错误\frontmatter

这是文件.tex

\documentclass{book}
\usepackage{amsmath}

\textheight4cm %short pages, to see the result
\begin{document}

\makeatletter
\everymath{%
  \ifodd\thepage\allowdisplaybreaks[0]%
    \else \allowdisplaybreaks[4]%
  \fi
}
\makeatother

\frontmatter
Some text

\begin{align*} %an example of action
a & b\\
c& d\\
e& f\\
g &h
\end{align*}

\begin{align*}
a & b\\
c& d\\
e& f\\
g &h
\end{align*}

\begin{align*}
a & b\\
c& d\\
e& f\\
g &h
\end{align*}

\begin{align*}
a & b\\
c& d\\
e& f\\
g &h
\end{align*}

\end{document}

答案1

\thepageinfrontmatter是罗马格式,而\ifodd需要数字(阿拉伯格式,即 1、2、3 等)。您应该使用in\value{page}而不是\thepage

\makeatletter
\everymath{%
  \ifodd\value{page}\allowdisplaybreaks[0]%
    \else \allowdisplaybreaks[4]%
  \fi
}
\makeatother

这有效:

\documentclass{book}
\usepackage{amsmath}

\textheight4cm %short pages, to see the result
\begin{document}

\makeatletter
\everymath{%
  \ifodd\value{page}\allowdisplaybreaks[0]%
    \else \allowdisplaybreaks[4]%
  \fi
}
\makeatother

\frontmatter
Some text

\begin{align*} %an example of action
a & b\\
c& d\\
e& f\\
g &h
\end{align*}

\begin{align*}
a & b\\
c& d\\
e& f\\
g &h
\end{align*}

\begin{align*}
a & b\\
c& d\\
e& f\\
g &h
\end{align*}

\begin{align*}
a & b\\
c& d\\
e& f\\
g &h
\end{align*}

\end{document}

相关内容