答案1
我使用TikZ
并声明newtheoremstyle
了amsthm
文档。TikZ
创建背景和颜色并newtheoremstyle
定义标题、标题颜色、定理文本前后的间距等。
\documentclass{article}
\usepackage{xcolor}
\definecolor{amber}{rgb}{1.0, 0.49, 0.0}
\definecolor{cadmiumgreen}{rgb}{0.0, 0.42, 0.24}
\usepackage{amsthm}
\usepackage{tikz}
\newtheoremstyle{styleth}%
{3pt}% Space above
{3pt}% Space below
{}% Body font
{}% Indent amount
{\bfseries\color{amber}}% Theorem head font
{}% Punctuation after theorem head
{.5em}% Space after theorem head
{}% Theorem head spec (can be left empty, meaning ‘normal’)
\theoremstyle{styleth}
\newtheorem{thm}{Theorem}
\newtheoremstyle{styledef}%
{3pt}% Space above
{3pt}% Space below
{}% Body font
{}% Indent amount
{\bfseries\color{cadmiumgreen}}% Theorem head font
{}% Punctuation after theorem head
{.5em}% Space after theorem head
{}% Theorem head spec (can be left empty, meaning ‘normal’)
\theoremstyle{styledef}
\newtheorem{definition}{Definition}
\newcommand{\statedefsolid}[2][\textwidth]{
\par\noindent\tikzstyle{mybox} = [fill=yellow!20,
thick,rectangle,inner sep=6pt,path picture={\fill [green!50!black] ([xshift=-6.15cm]path picture bounding box.north) rectangle (path picture bounding box.south west);}]
\begin{tikzpicture}
\node [mybox] (box){%
\begin{minipage}{#1}{#2}\end{minipage}
};
\end{tikzpicture}
}
\newcommand{\statetheoremsolid}[2][\textwidth]{
\par\noindent\tikzstyle{mybox} = [draw=amber,fill=gray!17,
thick,rectangle,rounded corners,inner sep=6pt]
\begin{tikzpicture}
\node [mybox] (box){%
\begin{minipage}{#1}{#2}\end{minipage}
};
\end{tikzpicture}
}
\begin{document}
\statedefsolid{
\begin{definition}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus nec est venenatis, maximus purus eu, ultrices justo. Integer ac mattis lectus. Praesent luctus lectus orci, vitae congue elit tempus vitae. Maecenas accumsan aliquet gravida. Maecenas vitae quam et lectus imperdiet feugiat. Sed sodales ipsum a dolor lobortis pretium. Sed at ipsum ac ante sollicitudin vehicula tempus a arcu. Integer volutpat malesuada nibh, at laoreet leo maximus non. Nulla vitae pulvinar erat.
\end{definition}
}
\statetheoremsolid{
\begin{thm}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus nec est venenatis, maximus purus eu, ultrices justo. Integer ac mattis lectus. Praesent luctus lectus orci, vitae congue elit tempus vitae. Maecenas accumsan aliquet gravida. Maecenas vitae quam et lectus imperdiet feugiat. Sed sodales ipsum a dolor lobortis pretium. Sed at ipsum ac ante sollicitudin vehicula tempus a arcu. Integer volutpat malesuada nibh, at laoreet leo maximus non. Nulla vitae pulvinar erat.
\end{thm}
}
\end{document}
编辑:为了更好地控制小页面的宽度,请同时更改newcommands
:
\newcommand{\statedefsolid}[2]{
\par\noindent\tikzstyle{mybox} = [fill=yellow!20,
thick,rectangle,inner sep=6pt,path picture={\fill [green!50!black] ([xshift=-6.15cm]path picture bounding box.north) rectangle (path picture bounding box.south west);}]
\begin{tikzpicture}
\node [mybox] (box){%
\begin{minipage}{#1}{#2}\end{minipage}
};
\end{tikzpicture}
}
\newcommand{\statetheoremsolid}[2]{
\par\noindent\tikzstyle{mybox} = [draw=amber,fill=gray!17,
thick,rectangle,rounded corners,inner sep=6pt]
\begin{tikzpicture}
\node [mybox] (box){%
\begin{minipage}{#1}{#2}\end{minipage}
};
\end{tikzpicture}
}
现在,def/theorem 文本中的命令将需要更多一个控制 minipage 宽度的参数:
\statetheoremsolid{0.95\textwidth}{
\begin{thm}
...
\end{thm}
}