我想将公式编号放在奇数页的右侧,偶数页的左侧。我找到了这个 如何根据奇数页还是偶数页将公式编号放在左侧或右侧 但它似乎不适用于 scrbook 类。有什么关于如何修改它的想法吗?
以下是 MWE:
\documentclass[12pt,a4paper]{scrbook}
\usepackage{amsmath}
\linespread{1.5}
\makeatletter
\def\mathlabel#1{\@bsphack
\protected@write\@auxout{}%
{\string\newlabel{#1}{{\@currentlabel}{\thepage}}}%
\@esphack}
\def\eqnWrite{\@bsphack
\protected@write\@auxout{}%
{\string\EqnStat{\theequation}{\thepage}}%
\@esphack}%
\def\EqnStat#1#2{%
\expandafter\gdef\csname eqn@#1\endcsname{#2}%
}
\newcommand\@reqnnum{\hb@[email protected]\p@{}%
\rlap{\normalfont\normalcolor%
\hskip -\displaywidth(\theequation)}}
\def\equation{\let\mathlabel\label$$\refstepcounter{equation}}
\def\endequation{\eqno\eqnWrite\@ifundefined{eqn@\theequation}{\hbox{\@eqnnum}}%%
{\expandafter\ifodd\csname eqn@\theequation\endcsname\hbox{\@reqnnum}%
\else\hbox{\@eqnnum}\fi}$$\@ignoretrue}
\def\@@eqncr{\let\reserved@a\relax%
\ifcase\@eqcnt \def\reserved@a{& & &}\or \def\reserved@a{& &}%
\or \def\reserved@a{&}\else%
\let\reserved@a\@empty%
\@latex@error{Too many columns in eqnarray environment}\@ehc\fi%
\reserved@a \if@eqnsw\eqnWrite%
\@ifundefined{eqn@\theequation}{\@eqnnum}%
{\expandafter\ifodd\csname eqn@\theequation\endcsname\@reqnnum%
\else\@eqnnum\fi}\stepcounter{equation}\fi%
\global\@eqnswtrue\global\@eqcnt\z@\cr}
\makeatother
\begin{document}
\begin{equation}
y = ax + b
\end{equation}
\begin{equation}
a^n + b^n = c^n
\end{equation}
\end{document}
用 report 替换 scrbook 效果很好。
答案1
我不知道该scrbook
课程,但也许以下内容会有所帮助,基于changepage
奇数/偶数页检查的包规定。
%\documentclass...
\usepackage{changepage} \strictpagecheck
\newcommand{\leftright}{%
\checkoddpage
\ifoddpage
% code for right eqno (which depends on your class and packages)
\else
% code for left eqno (which depends on your class and packages)
\fi}
% ...
\begin{equation} \leftright
% ...
\end{equation}
% ...
如果您不想\leftright
在每个之后继续添加\begin{equation}
,您可以将其添加到方程定义中,例如:
\let\oldequation=\equation
\renewcommand*{\equation}{\oldequation \leftright}
然后只需使用\begin{equation}
而不是\begin{equation} \leftright
。