如何防止 thmbox 渲染超过页码

如何防止 thmbox 渲染超过页码

我正在使用thmbox,但似乎它不能正确理解页面大小。当它在页面之间分割一个框时,有时会覆盖页码。这是我的文档中的错误,还是它extreport与 不兼容thmbox,或者这只是 thmbox 中的一个错误?有办法修复它吗?如果我完全关闭切割,如所述这里,它不再覆盖页码,但现在它拒绝在页面之间剪切方框,这对于长定理等来说不利。

我附上了一个非常小的可行示例。很难生成一个非常短的示例,因为它似乎是由长文档触发的。此 LaTeX 代码生成一个 5 页的文档。您可以在第 4 页底部看到错误,其中决定因素在页面之间剪切,页码 (4) 被数学公式覆盖。$a_{1k}$

公式写在页码上

这是混乱定义的缩小视图。

定理框定义

我还注意到数学方程式超出了定理框。也许这与数学模式有关extreport?但是,我只看到框内的方程式存在问题。

\documentclass[14pt]{extreport}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{thmbox}

\newtheorem[bodystyle=\normalfont\noindent]{theorem}{Theorem}[section]
\newtheorem[bodystyle=\normalfont\noindent]{definition}[theorem]{Definition}

\newcommand\jleft{\mathopen{}\mathclose\bgroup\left}
\newcommand\jright{\aftergroup\egroup\right}
\newcommand\jparen[1]{\jleft(#1\jright)}
\newcommand\supress[2]{{\mathfrak{S}_{#2}\jparen{#1}}}
\newcommand\cvec[1]{\begin{bmatrix} #1 \end{bmatrix}}
\newcommand{\abs}[1]{{\left| #1 \right|}}

\title{Practical Linear Algebra}
\author{Jim Newton}
\begin{document}

\chapter{Matrices}
\label{ch.matrices}
\section{Definition}

What is a matrix?

\begin{enumerate}
\item Mathematical definition.
\item Representing in Python
\end{enumerate}

\section{Addition}

Matrices are added component-wise.
If two matrices $A$ and $B$ each have dimensions $n\times m$, i.e., $n$ rows and $m$ columns,
then the can be added and the compnent in the row $i$ column $j$ of the sum
is exactly $c_{ij}=a_{ij}+b_{ij}$.
\begin{align*}
  \begin{bmatrix}
    a_{11}&a_{12}&\cdots&a_{1m}\\
    a_{21}&a_{22}&\cdots&a_{2m}\\
    \vdots & \vdots &&\vdots\\
    a_{n1}&a_{n2}&\cdots&a_{nn}
  \end{bmatrix} +
  \begin{bmatrix}
    b_{11} & b_{12}  &\cdots & b_{1n}\\
    b_{21} & b_{22}  &\cdots & b_{2n}\\
    \vdots & \vdots &       & \vdots\\
    b_{n1}  & b_{n2} &\cdots & b_{nn}
  \end{bmatrix} =\\
  \begin{bmatrix}
    a_{11}+b_{11} & a_{12}+b_{12} & \cdots & a_{1n}+b_{1n}\\
    a_{21}+b_{21} & a_{22}+b_{22} & \cdots & a_{2n}+b_{2n}\\
    \vdots & \vdots & &\vdots\\
    a_{n1}+b_{n1} & a_{n2}+b_{n2} & \cdots & a_{nn}+b_{nn}
  \end{bmatrix}
\end{align*}

Matrix addition is commutative when the components are themselves
commutative.  For example if the components are integers or real
numbers.

The $n\times m$ zero matrix is the additive identity for the set of $n\times m$ matrices.

\section{Multiplication}
Two matrices, $A$ and $B$, can be multiplied if their dimensions are
compatible.  The requirement is that an $n\times k$ (on the left) can
be multiplied by a $k \times n$ matrix to obtain an $n\times m$
matrix.

Matrix multiplication is, in general, not commutative.  However, there
do exist pairs of matricies which are commutative under
multiplication.  E.g., $A^n \times A^m = A^{n+m} = A^{m+n} = A^m\times
A^n$.  Also if a matrix is invertable, then $A \times A^{-1} = I =
A^{-1}\times A$.

We may multiply two matricies
\begin{align*}
  A &= \begin{bmatrix}
    a_{11}&a_{12}&\cdots&a_{1k}\\
    a_{21}&a_{22}&\cdots&a_{2k}\\
    \vdots & \vdots &&\vdots\\
    a_{n1}&a_{n2}&\cdots&a_{nk}
  \end{bmatrix}\\
  B &=
  \begin{bmatrix}
    b_{11} & b_{12}  &\cdots & b_{1n}\\
    b_{21} & b_{22}  &\cdots & b_{2n}\\
    \vdots & \vdots &       & \vdots\\
    b_{k1}  & b_{k2} &\cdots & b_{kn}
  \end{bmatrix},
\end{align*}
to obtain a matrix with dimensions $n\times m$, and the component
$c_{ij}$, row $i$, column $j$, is exactly
\begin{equation}
  c_{ij} = \sum_{k=1}^{k}a_{ik}b_{kj}
\end{equation}

There are many ways to think about this.  One way is that we
\emph{multiply} the rows of $A$ by the columns of $B$.  Another way to
think about it is that each $c_{ij}$ is the dot product of two
vectors, the i'th row vector from $A$ with the j'th column vector of
$B$.  The dot product of two vectors having the same dimension is:
\begin{equation}
  \cvec{a_1\\a_2\\\vdots\\a_n} \cdot   \cvec{b_1\\b_2\\\vdots\\b_n} = \sum_{k=1}^{n} a_kb_k\,.
\end{equation}


There is an identity matrix for multiplication provided the matrices in question are square.
The identity matrix is denoted $I$
\begin{equation}
  I = \begin{bmatrix}
 1 & 0 & 0 & \cdots &  0 \\
 0 & 1 & 0 & \cdots &  0 \\
 0 & 0 & 1 & \cdots &  0 \\
 \vdots & \vdots & \vdots & \ddots &  \vdots  \\
 0 & 0 &  0     & \cdots     &    1
\end{bmatrix}
\end{equation}

For any square matrix $A$, we have $I\times A = A\times I = A$.

\section{Determinant}
We will present a method to compute the \emph{determinant} of a square
matrix, called the \emph{Laplacian expansion} method.

The determinant of a matrix which tells us whether the matrix has an
inverse.  Some square matrices have an inverse and some do not.  If
$\det\jparen{A}\ne 0$, then there exists a matrix, which we denote
$A^{-1}$, for which $A\times A^{-1} = A^{-1}A = I$.  The inverse of a
matrix is compute intensive to calculate. In Chapter 3
we will begin talking about ways of computing the inverse.

Given an $n\times m$ matrix:
\begin{equation}
  A = \begin{bmatrix}
    a_{11}&a_{12}&\cdots&a_{1m}\\
    a_{21}&a_{22}&\cdots&a_{2m}\\
    \vdots & \vdots &\ddots&\vdots\\
    a_{n1}&a_{n2}&\cdots&a_{nm}
  \end{bmatrix}\,,
\end{equation}
we first define $\supress{A}{i,j}$ as the $(n-1) \times (m-1)$ matrix
formed by supressing the i'th row and j'th column of $A$.


\begin{definition}[determinant]\label{def.determinant}
We may define the determinant of a square, $n\times n$  matrix as:
\begin{equation}
  \det\jparen{A} = \begin{cases}
    a_{11} & \text{if } n = 1\\
    \sum\limits_{k=1}^{n}(-1)^k a_{1k} \det\jparen{\supress{A}{1,k}} & \text{if } n > 1
    \end{cases}
\end{equation}

We may also denote $\det\jparen{A}$ as $\abs{A}$.
\end{definition}


\end{document}

答案1

分页问题

我不知道这个答案是否是你想要的。你链接的帖子有一个后续问题这里,其中 OP 想要在不使用该选项的情况下解决问题nocut

正如那里所建议的,我认为你应该使用tcolorbox而不是thmbox,因为他的破解算法更为复杂。

通过替换以下行:

\usepackage{thmbox}

\newtheorem[bodystyle=\normalfont\noindent]{theorem}{Theorem}[section]
\newtheorem[bodystyle=\normalfont\noindent]{definition}[theorem]{Definition}

使用以下代码:

\usepackage[most]{tcolorbox}

\newlength{\thmboxvlineindent}
\setlength{\thmboxvlineindent}{\dimexpr21.14975pt-0.4em-0.3pt}

\tcbset{
    thmbox/.style={
        enhanced,
        breakable,
        sharp corners=all,
        fonttitle=\bfseries,
        fontupper=\normalfont,
        top=0mm,
        bottom=0mm,
        right=0mm,
        left=\dimexpr\thmboxvlineindent-0.3pt,
        boxsep=0.4em,
        colback=white,
        colframe=white,
        colbacktitle=white,
        coltitle=black,
        attach boxed title to top left,
        boxed title style={empty, size=minimal, bottom=2.5pt},
        before upper={\parindent=21.14975pt\noindent},
        left skip=\parskip,
        overlay unbroken ={
            \draw[line width=0.6pt] (title.south west)--(title.south east);
            \draw[line width=0.6pt] ([xshift=\thmboxvlineindent]frame.north west)--([xshift=\thmboxvlineindent]frame.south west)--++(0:0.3pt);
            \draw[line width=0.6pt] ([xshift=\thmboxvlineindent]frame.south west)--++(0:1cm);},
        overlay first={
            \draw[line width=0.6pt] (title.south west)--(title.south east); 
            \draw[line width=0.6pt] ([xshift=\thmboxvlineindent]frame.north west)--([xshift=\thmboxvlineindent]frame.south west);},
        overlay middle={
            \draw[line width=0.6pt] ([xshift=\thmboxvlineindent]frame.north west)--([xshift=\thmboxvlineindent]frame.south west);},
        overlay last={
            \draw[line width=0.6pt] ([xshift=\thmboxvlineindent]frame.north west)--([xshift=\thmboxvlineindent]frame.south west)--++(0:0.3pt);
            \draw[line width=0.6pt] ([xshift=\thmboxvlineindent]frame.south west)--++(0:1cm);}
    }
}

\newcounter{theorem}[section]
\renewcommand*\thetheorem{\thesection.\arabic{theorem}}
\newtcbtheorem[number within=section]
{thm}
{Theorem \thetheorem}
{thmbox,description font=\itshape,description delimiters={{\normalfont\bfseries(}}{\normalfont\bfseries)},separator sign none}{}
\newtcbtheorem[use counter from=thm]
{defn}
{Definition \thetheorem}
{thmbox,description font=\itshape,description delimiters={{\normalfont\bfseries(}}{\normalfont\bfseries)},separator sign none}{}


\newenvironment{theorem}[1][]{\refstepcounter{theorem}\csname thm*\endcsname{#1}{}}{\endthm}
\newenvironment{definition}[1][]{\refstepcounter{theorem}\csname defn*\endcsname{#1}{}}{\enddefn}

您应该能够在文档主体中使用具有相同语法的定理环境。

该代码基于这个答案,但应具有与原始定理相同的尺寸(相同的线条粗细、相同的边距等)和相同的标题格式。

另一种解决方案

您还可以使用 tcolorbox 作为定理环境。启动定理的语法是\begin{<env name>}{<theorems title>}{label}。虽然这些是必需的参数,但它们可以留空。

声明的最后一个参数为tcbtheorem定理的标签定义了一个前缀。在下面的代码中,我将在定义环境的标签中添加一个 def. 前缀,(点也将自动添加)。使用此代码,示例中的定义应以 开头\begin{definition}{determinant}{determinant},并且应使用 来引用它\ref{def.determinant}

\usepackage[most]{tcolorbox}

\newlength{\thmboxvlineindent}
\setlength{\thmboxvlineindent}{\dimexpr21.14975pt-0.4em-0.3pt}

\tcbset{
    thmbox/.style={
        enhanced,
        breakable,
        sharp corners=all,
        fonttitle=\bfseries,
        fontupper=\normalfont,
        top=0mm,
        bottom=0mm,
        right=0mm,
        left=\dimexpr\thmboxvlineindent-0.3pt,
        boxsep=0.4em,
        colback=white,
        colframe=white,
        colbacktitle=white,
        coltitle=black,
        attach boxed title to top left,
        boxed title style={empty, size=minimal, bottom=2.5pt},
        before upper={\parindent=21.14975pt\noindent},
        left skip=\parskip,
        overlay unbroken ={
            \draw[line width=0.6pt] (title.south west)--(title.south east);
            \draw[line width=0.6pt] ([xshift=\thmboxvlineindent]frame.north west)--([xshift=\thmboxvlineindent]frame.south west)--++(0:0.3pt);
            \draw[line width=0.6pt] ([xshift=\thmboxvlineindent]frame.south west)--++(0:1cm);},
        overlay first={
            \draw[line width=0.6pt] (title.south west)--(title.south east); 
            \draw[line width=0.6pt] ([xshift=\thmboxvlineindent]frame.north west)--([xshift=\thmboxvlineindent]frame.south west);},
        overlay middle={
            \draw[line width=0.6pt] ([xshift=\thmboxvlineindent]frame.north west)--([xshift=\thmboxvlineindent]frame.south west);},
        overlay last={
            \draw[line width=0.6pt] ([xshift=\thmboxvlineindent]frame.north west)--([xshift=\thmboxvlineindent]frame.south west)--++(0:0.3pt);
            \draw[line width=0.6pt] ([xshift=\thmboxvlineindent]frame.south west)--++(0:1cm);}
    }
}

\newtcbtheorem[number within=section]
{theorem}
{Theorem}
{thmbox,description font=\itshape,description delimiters={{\normalfont\bfseries(}}{\normalfont\bfseries)},separator sign none,label separator=.}{theo} % the last argument here, i.e. "theo", is the prefix for the label.
\newtcbtheorem[use counter from=theorem]
{definition}
{Definition}
{thmbox,description font=\itshape,description delimiters={{\normalfont\bfseries(}}{\normalfont\bfseries)},separator sign none,label separator=.}{def}

定理框外的方程

通常 TeX 不会破坏显示数学方程,所以这不是问题extreport。如果你想写宽显示数学方程,你应该使用例如包align提供的环境。amsmath

相关内容