使用 Psvectorian 定制定理环境

使用 Psvectorian 定制定理环境

我想知道是否有办法使用 Psvectorian 自定义定理环境。为了澄清这一点,请考虑以下代码:

\documentclass[12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[framemethod=tikz]{mdframed}

%-- Customize Define Enviroment --

\newtheorem{theorem}{Theorem}
\surroundwithmdframed[ linewidth=1pt,
     linecolor=black,
     bottomline=false,topline=false,rightline=false,
     innerrightmargin=0pt,innertopmargin=0pt,innerbottommargin=0pt,
     innerleftmargin=1em,% Distance between vertical rule & proof content
     skipabove=.5\baselineskip]{theorem}

\begin{document}
% Some equations defined earlier...
% Now comes the theorem
% -- Theorem Example --

\begin{theorem}[\textsc{Necessary Conditions for Optimality (NOC)}]
Let $\mathbf{x}^*$ be an unconstrained local minimum of $f:\R^n \to \R$ and $f \in C^1$ in an open set $S$ containing $\mathbf{x}^*$. Then,
\begin{equation}
    \nabla f(\mathbf{x}^*) = 0.
\end{equation}
If $f \in C^2$ within $S$, $\nabla^2 f(\mathbf{x}^*)$ is positive semidefinite. 
\end{theorem}

\end{document}

这应该会产生以下内容: 在此处输入图片描述

现在,基于令人惊叹的 Psvectorian 包,有许多漂亮的装饰品,我在这里看到许多使用它们来定制章节和章节的例子。

我想知道我们是否也可以使用这些装饰来定制定理环境。特别是,是否可以用 Psvectorian 包中的一些漂亮装饰来替换上面定理示例中显示的“垂直黑线”?我将非常感谢任何示例或建议。

答案1

这更像是一个展示,而不是一个通用的解决方案。它是一种使用tcolorbox和的方法pgfornament。但是它不是自动的,您需要根据定理的长度手动调整要形成左侧和右侧框架的段数。如果定理长于一页或在分页符附近输入,则可以将其拆分。但是,您还需要根据可拆分框架的长度指定第一部分段数和最后一部分段数。适当的段数还取决于页面布局。此处的示例仅适用于该特定页面布局。pgfornament包现在提供从 80 到 89 的行模式,您可以选择其中之一。如果使用其他类型的 pgfornament,它将不适合框架。我为环境设置了 4 个可选参数和 1 个强制参数mybox。语法如下:

\begin{mybox}[normal tcolorbox options][unbreakable frame left and right segment numbers][breakable frame first part left and right segment numbers][breakable frame last part left and right segment numbers]{pgfornament pattern number(80-89)}
Contents...
\end{mybox}
\documentclass[12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{geometry}
\usepackage[most]{tcolorbox}
\DeclareTColorBox{mybox}{O{} O{1} O{4} O{4} m}{
enhanced,
breakable,
opacityback=0,
bottom=10pt,
after=\vspace{0.5cm},
frame code={
\begin{scope}[every node/.style={color=green!30!black}]
\pgfornamentline{frame.south west}{frame.north west}{#2}{#5}
\pgfornamentline{frame.north west}{frame.north east}{3}{#5}
\pgfornamentline{frame.north east}{frame.south east}{#2}{#5}
\pgfornamentline{frame.south west}{frame.south east}{3}{#5}
\end{scope}
},
skin first is subskin of={enhancedfirst}{%
        frame code={
        \begin{scope}[every node/.style={color=green!30!black}]
        \pgfornamentline{frame.south west}{frame.north west}{#3}{#5}
        \pgfornamentline{frame.north west}{frame.north east}{3}{#5}
        \pgfornamentline{frame.north east}{frame.south east}{#3}{#5}
        \pgfornamentline{frame.south west}{frame.south east}{3}{#5}
        \end{scope}
        },
},
skin middle is subskin of={enhancedmiddle}{%
        frame code={
        \begin{scope}[every node/.style={color=green!30!black}]
        \pgfornamentline{frame.south west}{frame.north west}{4}{#5}
        \pgfornamentline{frame.north west}{frame.north east}{3}{#5}
        \pgfornamentline{frame.north east}{frame.south east}{4}{#5}
        \pgfornamentline{frame.south west}{frame.south east}{3}{#5}
        \end{scope}
        },
},
skin last is subskin of={enhancedlast}{%
        frame code={
        \begin{scope}[every node/.style={color=green!30!black}]
        \pgfornamentline{frame.south west}{frame.north west}{#4}{#5}
        \pgfornamentline{frame.north west}{frame.north east}{3}{#5}
        \pgfornamentline{frame.north east}{frame.south east}{#4}{#5}
        \pgfornamentline{frame.south west}{frame.south east}{3}{#5}
        \end{scope}
        },
},
#1
}
\usepackage{pgfornament}
\usepackage{lipsum}
\newtheorem{theorem}{Theorem}

\begin{document}
\pagecolor{yellow!20}
\begin{mybox}[top=20pt,bottom=20pt]{81}
\begin{theorem}[\textsc{Necessary Conditions for Optimality (NOC)}]
Let $\mathbf{x}^\ast$ be an unconstrained local minimum of $f:R^n \to R$ and $f \in C^1$ in an open set $S$ containing $\mathbf{x}^\ast$. Then,
\begin{equation}
    \nabla f(\mathbf{x}^*) = 0.
\end{equation}
If $f \in C^2$ within $S$, $\nabla^2 f(\mathbf{x}^\ast)$ is positive semidefinite. 
\end{theorem}
\end{mybox}

\begin{mybox}[][2]{87}
\begin{theorem}[\textsc{Necessary Conditions for Optimality (NOC)}]
Let $\mathbf{x}^\ast$ be an unconstrained local minimum of $f:R^n \to R$ and $f \in C^1$ in an open set $S$ containing $\mathbf{x}^\ast$. Then,
\begin{equation}
    \nabla f(\mathbf{x}^*) = 0.
\end{equation}
If $f \in C^2$ within $S$, $\nabla^2 f(\mathbf{x}^\ast)$ is positive semidefinite.
\lipsum[1]
\end{theorem}
\end{mybox}

\begin{mybox}[][][1][2]{85}
\begin{theorem}[\textsc{Necessary Conditions for Optimality (NOC)}]
Let $\mathbf{x}^\ast$ be an unconstrained local minimum of $f:R^n \to R$ and $f \in C^1$ in an open set $S$ containing $\mathbf{x}^\ast$. Then,
\begin{equation}
    \nabla f(\mathbf{x}^*) = 0.
\end{equation}
If $f \in C^2$ within $S$, $\nabla^2 f(\mathbf{x}^\ast)$ is positive semidefinite. 

\lipsum[1-6]
\end{theorem}
\end{mybox}
\end{document}

在此处输入图片描述

相关内容