# Customizing Theorem Enviroment using Psvectorian

I was wondering if there is a way we can customize theorem environment using Psvectorian. To clarify, consider the following code:

\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,
$$\nabla f(\mathbf{x}^*) = 0.$$
If $f \in C^2$ within $S$, $\nabla^2 f(\mathbf{x}^*)$ is positive semidefinite.
\end{theorem}

\end{document}


This should produce the following:

Now, based on the amazing Psvectorian package, there are many beautiful ornaments and I've seen many examples here where they're used to customize sections and chapters.

I was wondering if we can also customize theorem environments with these ornaments. In particular, is it possible to replace the "vertical black line" shown in the theorem example above with some beautiful ornament from the Psvectorian package? I would be truly grateful for any examples or suggestions.

This is more like a showcase, not a general solution. It is a method using tcolorbox and pgfornament. However it was not automatic, you need manfully adjust how many segments you want to form the left and right side frame depends on the length of your theorem. If the theorem longer than one pages or it be typed near the page break, it can be breakable. However you also need to specify the first part segments number and last part segments number for the breakable frame according to their length. The proper segments number also depends on the page layout. The example here is only working in this particular page layout. pgfornament package right now offer lines pattern from number 80 to 89, you can choose one of them. If you use other type's pgfornament, it won't fit the frame. I set 4 optional args and 1 mandatory arg for the mybox environment. The syntax is like this:

\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,
$$\nabla f(\mathbf{x}^*) = 0.$$
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,
$$\nabla f(\mathbf{x}^*) = 0.$$
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,
$$\nabla f(\mathbf{x}^*) = 0.$$
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}