我希望将我的定理风格定制为如图所示的风格,但我无法找到参数的通用定义。有什么建议吗?
代码:
\documentclass{article}
\usepackage{tikz}
\newcommand\Loadedframemethod{TikZ}
\usepackage[framemethod=\Loadedframemethod]{mdframed}
\tikzstyle{titregris} =
[draw=gray, thick, fill=white, shading = exersicetitle, %
text=black, rectangle, rounded corners, right,minimum height=.7cm]
\pgfdeclarehorizontalshading{exersicebackground}{100bp}
{color(0bp)=(white); color(100bp)=(white!5)}
\pgfdeclarehorizontalshading{exersicetitle}{100bp}
{color(0bp)=(white);color(100bp)=(black!5)}
\newcounter{exercise}
\renewcommand*\theexercise{Example:~\arabic{exercise}}
\makeatletter
\def\mdf@@exercisepoints{}%new mdframed key:
\define@key{mdf}{exercisepoints}{%
\def\mdf@@exercisepoints{#1}
}
\mdfdefinestyle{exercisestyle}{%
outerlinewidth=1em,outerlinecolor=white,%
leftmargin=-1em,rightmargin=-1em,%
middlelinewidth=1.2pt,roundcorner=5pt,linecolor=gray,
apptotikzsetting={\tikzset{mdfbackground/.append style ={%
shading = exersicebackground}}},
innertopmargin=1.2\baselineskip,
skipabove={\dimexpr0.5\baselineskip+\topskip\relax},
skipbelow={-1em},
needspace=3\baselineskip,
frametitlefont=\sffamily\bfseries,
settings={\global\stepcounter{exercise}},
singleextra={%
\node[titregris,xshift=1cm] at (P-|O) %
{~\mdf@frametitlefont{\theexercise}~};
\ifdefempty{\mdf@@exercisepoints}%
{}%
{\node[titregris,left,xshift=-1cm] at (P)%
{~\mdf@frametitlefont{\mdf@@exercisepoints points}~};}%
},
firstextra={%
\node[titregris,xshift=1cm] at (P-|O) %
{~\mdf@frametitlefont{\theexercise}~};
\ifdefempty{\mdf@@exercisepoints}%
{}%
{\node[titregris,left,xshift=-1cm] at (P)%
{~\mdf@frametitlefont{\mdf@@exercisepoints points}~};}%
},
}
\makeatother
\begin{document}
\begin{mdframed}[style=exercisestyle]
Near what I want
\end{mdframed}
\end{document}
答案1
我希望你已经解决了这个问题(因为你之前就发过这个帖子)。如果没有,以下是我的两个解决方案:
- 使用包装的不易破碎的盒子
environ
:\NewEnviron{sqbrrotnbr}
- 一个易碎的盒子使用
tcolorbox
包装(而不是mdframed
- 这是一个品味问题(?)):\newenvironment{sqbrrotbr}
\documentclass{article}
\usepackage{lipsum} % for the sake of demonstration
\usepackage[a5paper]{geometry} % for the sake of demonstration
\usepackage{environ}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage[many]{tcolorbox}
\NewEnviron{sqbrrotnbr}[1]{
\par\vspace{0.5\baselineskip}\noindent
\begin{tikzpicture}
\node (body) [
text justified,
text width=\textwidth-4pt-2ex,
inner sep=0pt,
] {\BODY};
\draw [
line width=0.5pt,
black,
] ($(body.south east)+( 5pt, 4pt)$) |-
($(body.south) +( 0pt,-5pt)$) -|
($(body.south west)+(-5pt, 4pt)$)
($(body.north west)+(-5pt, 0pt)$) |-
($(body.north) +( 0pt,+9pt)$) -|
($(body.north east)+( 5pt, 0pt)$);
\node [black,fill=white] at ($(body.north west)+(35pt,10pt)$) {\sffamily\bfseries #1};
\end{tikzpicture}
\par\vspace{0.25\baselineskip}
}
\newenvironment{sqbrrotbr}[1]{
\par\vspace{0.5\baselineskip}
\begin{tcolorbox}[
blank,
breakable,
parbox=false,
top=5pt,
left=5pt,
bottom=5pt,
right=5pt,
overlay first={
\draw[
black,
line width=0.5pt,
] ($(interior.north west)+( 0pt,-5pt)$) |-
($(interior.north) +( 0pt, 4pt)$) -|
($(interior.north east)+( 0pt,-5pt)$);
\node [black,fill=white] at ($(interior.north west)+(40pt, 4pt)$) {\sffamily\bfseries #1};
},
overlay last={
\draw[
black,
line width=0.5pt,
] ($(interior.south east)+( 0pt,10pt)$) |-
($(interior.south) +( 0pt, 0pt)$) -|
($(interior.south west)+( 0pt,10pt)$);},
]{#1}
}{
\end{tcolorbox}
\par\vspace{0.5\baselineskip}
}
\begin{document}
\textbf{Sq}uare \textbf{Br}ackets \text{Rot}ated - \textbf{N}on-\textbf{br}eaking \hrulefill\\
\begin{sqbrrotnbr}{Title}
\lipsum[1]
\end{sqbrrotnbr}
\vspace{36pt}
\textbf{Sq}uare \textbf{Br}ackets \text{Rot}ated - \textbf{Br}eaking \hrulefill\\
\begin{sqbrrotbr}{Title}
\lipsum[3]
\end{sqbrrotbr}
\end{document}
注意:还有一些我没有检查过的坏盒子。