我已经使用 LaTex 有一段时间了,使用 Tikz 我做了一些没什么特别的东西,只是为了做作业,但现在我要写我的论文,我想要一些使用 mdframed 的优雅酷定理框,这是我所做的事情的代码
\documentclass{book}
{\usepackage[framemethod=TikZ]{mdframed}
\mdfdefinestyle{Teorema}{
frametitlerule=false,
linecolor=black,%FireBrick
linewidth=1pt,
innerlinewidth =1pt,
frametitlerulewidth=2pt,
frametitlebackgroundcolor=blue!40,%DarkSalmon
backgroundcolor=gray!10,
skipbelow=15pt,
}
\mdtheorem[style=Teorema]{teorema}{Teorema}}
我应该在代码中修改什么才能得到这样的结果
我阅读了mdframed
手册,但我真的不知道他们为什么使用某些命令。
谢谢
答案1
以 为例tcolorbox
。
\documentclass[12pt]{article}
\usepackage[many]{tcolorbox}
\newtcbtheorem[number within=section]{mytheo}{My Theorem}%
{colback=white,colframe=blue!50,fonttitle=\bfseries,
enhanced,
coltitle=blue!75!black,
attach boxed title to top left=
{xshift=2ex,yshift=-2mm,yshifttext=-1mm},
boxed title style={colframe=blue!50,
colback=blue!50}}{th}
\begin{document}
\begin{mytheo}{This is my title}{theoexample}
This is the text of the theorem. The counter is automatically assigned and,
in this example, prefixed with the section number. This theorem is numbered with
\ref{th:theoexample} and is given on page \pageref{th:theoexample}.
\end{mytheo}
\end{document}
这是根据手册修改的示例,mdframed
以便可以编译。
\documentclass{article}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage[framemethod=TikZ]{mdframed}
%% the following is commaon for all examples in mdframed manual
\mdfsetup{skipabove=\topskip,skipbelow=\topskip}
%%% upto here
\newcounter{theo}[section]
\newenvironment{theo}[1][]{%
\stepcounter{theo}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!20]
{\strut Theorem~\thetheo};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!20]
{\strut Theorem~\thetheo:~#1};}}%
}%
\mdfsetup{innertopmargin=10pt,linecolor=blue!20,%
linewidth=2pt,topline=true,
frametitleaboveskip=\dimexpr-\ht\strutbox\relax,}
\begin{mdframed}[]\relax%
}
{\end{mdframed}}
\begin{document}
\begin{theo}[Inhomogeneous Linear]
\ExampleText
\end{theo}
\begin{theo}
\ExampleText
\end{theo}
\end{document}
您所要做的就是在上方输入您的内容,begin{theo}
然后\end{theo}
点赞
\begin{theo}[Inhomogeneous Linear]
Your content here.
\end{theo}
例如:
\begin{theo}[Inhomogeneous Linear]
An \textit{inhomogeneous linear} differential equation has the form
\begin{align}
L[v] = f,
\end{align}
where $L$ is a linear differential operator, $v$ is the dependent
variable, and $f$ is a given non-zero function of the independent
variables alone.
\end{theo}