下面是我在这里询问的一些已开发的示例解决方案 tikz 和 mdframed + 阴影和着色
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1,T2A]{fontenc}
\usepackage[english,russian]{babel}
\usepackage[a5paper]{geometry}
\usepackage{amsthm,thmtools}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{amsmath,amssymb}
\usetikzlibrary{shadows.blur}
\usetikzlibrary{shapes.symbols}
\usetikzlibrary{shadows,shapes}
\usetikzlibrary{calc}
\usepackage{lipsum}
\newcounter{exercise}
\newtheorem{myexercise}{Exercise}[section]
\tikzset{myshadow/.style={ % custom shadow with tikz
opacity=.85,
shadow xshift=0.15,
shadow yshift=-0.15,
shade,
shading=axis,
shading angle=230}
}
\tikzstyle{titregris} =
[draw=gray, line width=1.0pt,%
text=white, rectangle,
right,minimum height=.7cm,
double,
shade,
top color=blue!40,
bottom color=blue!5,
rounded corners=8pt,
opacity=1,
shadow xshift=0.15,
shadow yshift=-0.15,
shade,
shading=axis,
shading angle=30,
drop shadow,
]
\tikzstyle{pointstyle} =
[draw=red, thick, fill=red,%
text=white, rectangle,
right,minimum height=.7cm,
double,
shade,
top color=red,
bottom color=blue!5,
rounded corners=3pt,
drop shadow
]
\renewcommand*\theexercise{Exercise \textnumero\arabic{exercise}}
\makeatletter
\def\mdf@@exercisepoints{}%new mdframed key:
\define@key{mdf}{exercisepoints}{%
\def\mdf@@exercisepoints{#1}
}
\def\mdf@@fig{}%new mdframed key:
\define@key{mdf}{fig}{%
\def\mdf@@fig{#1}
}
\def\mdf@@title{}%new mdframed key:
\define@key{mdf}{title}{%
\def\mdf@@title{#1}
}
\mdfdefinestyle{exercisestyle}{%
middlelinewidth=1.2pt,roundcorner=5pt,linecolor=gray,
%apptotikzsetting={\tikzset{mdfbackground/.append style ={%
%shading = exersicebackground}}},
apptotikzsetting={\tikzset{mdfbackground/.append style={top color=blue!40, bottom color=white}}},
innertopmargin=1.2\baselineskip,
skipabove={\dimexpr0.5\baselineskip+\topskip\relax},
skipbelow={-1em},
shadow=true,
shadowcolor=blue!35,
needspace=3\baselineskip,
frametitlefont=\sffamily\bfseries,
settings={\global\refstepcounter{exercise}},
singleextra={%
\node[titregris,xshift=1cm] at (P-|O) %
{~\mdf@frametitlefont{\theexercise}~\mdf@@title};
\ifdefempty{\mdf@@exercisepoints}%
{}%\node[fill=blue!40,font=\color{black},yshift=-51,circle,inner sep=1pt]
{\node[pointstyle,left,xshift=-1cm] at (P)%
{~\mdf@frametitlefont{\mdf@@exercisepoints pt.}~};},%
\ifdefempty{\mdf@@fig}%
{}%
{\path let \p1=(P), \p2=(O) in node[fill=blue!40,circle,inner sep=1pt,font=\color{white}] at (P|-0,0.5*\y2+0.5*\y1) {\mdf@@fig};}%
},
firstextra={%
\node[titregris,xshift=1cm] at (P-|O) %
{~\mdf@frametitlefont{\theexercise}~};
\ifdefempty{\mdf@@exercisepoints }%
{}%
{\node[pointstyle,left,xshift=-1cm] at (P)%
{~\mdf@frametitlefont{\mdf@@exercisepoints points}~};},%
{\node[pointstyle, left,xshift=1cm] {$\clubsuit$};}
},
}
\makeatother
\begin{document}
\begin{mdframed}[style=exercisestyle,exercisepoints=10,fig=$\spadesuit$,title= example $E=mc^2$]
%\begin{myexercise}
\begin{align}
\dot{n} &= u\cos\psi -v\sin\psi \\
\dot{e} &= u\sin\psi + v\cos\psi
\end{align}
For small angles the following approximation can be used:
\begin{align}
\dot{n} &= u -v\delta_\psi \\
\dot{e} &= u\delta_\psi + v
\end{align}
%\end{myexercise}
\end{mdframed}
\listoftheorems{myexercise}
\end{document}
几乎所有东西都可以传递,现在的问题是可以有“练习列表”和“添加到目录”命令吗?是的,这是一个目录,但它需要命令。对于 TiKZ,这里讨论了这个问题将 TikZ 代码添加到目录。我需要用另一个命令包装 mdframed 环境吗?或者还有其他方法吗?ps 我尝试使用 ntheorem 创建新的定理,但当我打印列表定理时,它不会以 utf-8 格式打印。这似乎与 fontencoding 冲突。LIRC 命令有问题,我放弃了 ntheorem
新问题从这里开始: 抱歉...我编辑并回滚了原始代码...这是在讨论过程中开发的代码。由于那个花哨的“西装”节点在页面上拆分框架时会出现问题,因此在下面的代码中我将其删除为默认节点。因此,当用户知道环境没有拆分时,他可以通过“右侧西装图”。以前,如果没有使用这个框架拆分是可以的...在下面的代码中出现了一个问题:环境标题丢失,只显示计数器值。
这是一个代码:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1,T2A]{fontenc}
\usepackage[english,russian]{babel}
\usepackage[a5paper]{geometry}
\usepackage{amsthm,thmtools}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{amsmath,amssymb}
\usetikzlibrary{shadows.blur}
\usetikzlibrary{shapes.symbols}
\usetikzlibrary{shadows,shapes}
\usetikzlibrary{calc}
\usepackage{lipsum}
\newcounter{exercise}
\newtheorem{myexercise}{Exercise}[section]
\tikzset{myshadow/.style={ % custom shadow with tikz
opacity=.85,
shadow xshift=0.15,
shadow yshift=-0.15,
shade,
shading=axis,
shading angle=230}
}
\tikzstyle{titregris} =
[draw=gray, line width=1.0pt,%
text=white, rectangle,
right,minimum height=.7cm,
double,
shade,
top color=blue!40,
bottom color=blue!5,
rounded corners=8pt,
opacity=1,
shadow xshift=0.15,
shadow yshift=-0.15,
shade,
shading=axis,
shading angle=30,
drop shadow,
]
\tikzstyle{pointstyle} =
[draw=red, thick, fill=red,%
text=white, rectangle,
right,minimum height=.7cm,
double,
shade,
top color=red,
bottom color=blue!5,
rounded corners=3pt,
drop shadow
]
%\renewcommand*\theexercise{Exercise \textnumero\arabic{exercise}}
\makeatletter
\def\mdf@@exercisepoints{}%new mdframed key:
\define@key{mdf}{exercisepoints}{%
\def\mdf@@exercisepoints{#1}
}
\def\mdf@@fig{}%new mdframed key:
\define@key{mdf}{fig}{%
\def\mdf@@fig{#1}
}
\def\mdf@@title{}%new mdframed key:
\define@key{mdf}{title}{%
\def\mdf@@title{#1}
}
\mdfdefinestyle{exercisestyle}{%
middlelinewidth=1.2pt,roundcorner=5pt,linecolor=gray,
apptotikzsetting={\tikzset{mdfbackground/.append style={top color=blue!40, bottom color=white}}},
innertopmargin=1.2\baselineskip,
skipabove={\dimexpr0.5\baselineskip+\topskip\relax},
skipbelow={-1em},
shadow=true,
shadowcolor=blue!35,
needspace=3\baselineskip,
frametitlefont=\sffamily\bfseries,
singleextra={%
\node[titregris,xshift=1cm] at (P-|O) %
{~\mdf@frametitlefont{Exercise~\textnumero\theexercise}~\mdf@@title};
\ifdefempty{\mdf@@exercisepoints}%
{}%\node[fill=blue!40,font=\color{black},yshift=-51,circle,inner sep=1pt]
{\node[pointstyle,left,xshift=-1cm] at (P)%
{~\mdf@frametitlefont{\mdf@@exercisepoints pt.}~};},%
\ifdefempty{\mdf@@fig}%
{}%
{\path let \p1=(P), \p2=(O) in node[fill=blue!40,circle,inner sep=1pt,font=\color{white}] at (P|-0,0.5*\y2+0.5*\y1) {\mdf@@fig};}%
},
firstextra={%
\node[titregris,xshift=1cm] at (P-|O) %
{~\mdf@frametitlefont{\theexercise}~};
\ifdefempty{\mdf@@exercisepoints }%
{}%
{\node[pointstyle,left,xshift=-1cm] at (P)%
{~\mdf@frametitlefont{\mdf@@exercisepoints points}~};},%
%{\node[pointstyle, left,xshift=1cm] {$\clubsuit$};}
},
}
\newcommand\listmdfname{List of Exercises}
\newcommand\listofmdframed{\section*{\listmdfname}%
\@mkboth{\MakeUppercase\listfigurename}%
{\MakeUppercase\listfigurename}%
\@starttoc{mdf}}
\newenvironment{mythm}[2][]
{\refstepcounter{exercise}\addcontentsline{mdf}{figure}{Exercise~\theexercise~#2}\begin{mdframed}[style=exercisestyle,#1,title=#2]}
{\end{mdframed}}
\makeatother
\begin{document}
\listofmdframed
\begin{mythm}[exercisepoints=10,fig=$\spadesuit$]{Example $E=mc^2$}
\begin{align}
\dot{n} &= u\cos\psi -v\sin\psi \\
\dot{e} &= u\sin\psi + v\cos\psi
\end{align}
For small angles the following approximation can be used:
\begin{align}
\dot{n} &= u -v\delta_\psi \\
\dot{e} &= u\delta_\psi + v
\end{align}
\end{mythm}
\begin{mythm}[exercisepoints=5,fig=$\spadesuit$]{Example $a=b$}
\begin{align}
\dot{n} &= u\cos\psi -v\sin\psi \\
\dot{e} &= u\sin\psi + v\cos\psi
\end{align}
For small angles the following approximation can be used:
\begin{align}
\dot{n} &= u -v\delta_\psi \\
\dot{e} &= u\delta_\psi + v
\end{align}
\end{mythm}
\vspace{0.1cm}
Here is problematic example:
\begin{mythm}[exercisepoints=10,]{Example Problematic}
\begin{align}
\dot{n} &= u\cos\psi -v\sin\psi \\
\dot{e} &= u\sin\psi + v\cos\psi
\end{align}
For small angles the following approximation can be used:
\begin{align}
\dot{n} &= u -v\delta_\psi \\
\dot{e} &= u\delta_\psi + v
\end{align}
\end{mythm}
\begin{mythm}[exercisepoints=5,fig=$\spadesuit$]{Example $a=b$}
\begin{align}
\dot{n} &= u\cos\psi -v\sin\psi \\
\dot{e} &= u\sin\psi + v\cos\psi
\end{align}
For small angles the following approximation can be used:
\begin{align}
\dot{n} &= u -v\delta_\psi \\
\dot{e} &= u\delta_\psi + v
\end{align}
\end{mythm}
\end{document}
我认为传递“MyTheoremEnv1”作为密钥而不是仅仅使用硬连线文本练习可以解决这个问题?
答案1
一种可能性是:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1,T2A]{fontenc}
\usepackage[english,russian]{babel}
\usepackage[a5paper]{geometry}
\usepackage{amsthm,thmtools}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{amsmath,amssymb}
\usetikzlibrary{shadows.blur}
\usetikzlibrary{shapes.symbols}
\usetikzlibrary{shadows,shapes}
\usetikzlibrary{calc}
\usepackage{lipsum}
\newcounter{exercise}
\newtheorem{myexercise}{Exercise}[section]
\tikzset{myshadow/.style={ % custom shadow with tikz
opacity=.85,
shadow xshift=0.15,
shadow yshift=-0.15,
shade,
shading=axis,
shading angle=230}
}
\tikzstyle{titregris} =
[draw=gray, line width=1.0pt,%
text=white, rectangle,
right,minimum height=.7cm,
double,
shade,
top color=blue!40,
bottom color=blue!5,
rounded corners=8pt,
opacity=1,
shadow xshift=0.15,
shadow yshift=-0.15,
shade,
shading=axis,
shading angle=30,
drop shadow,
]
\tikzstyle{pointstyle} =
[draw=red, thick, fill=red,%
text=white, rectangle,
right,minimum height=.7cm,
double,
shade,
top color=red,
bottom color=blue!5,
rounded corners=3pt,
drop shadow
]
%\renewcommand*\theexercise{Exercise \textnumero\arabic{exercise}}
\makeatletter
\def\mdf@@exercisepoints{}%new mdframed key:
\define@key{mdf}{exercisepoints}{%
\def\mdf@@exercisepoints{#1}
}
\def\mdf@@fig{}%new mdframed key:
\define@key{mdf}{fig}{%
\def\mdf@@fig{#1}
}
\def\mdf@@title{}%new mdframed key:
\define@key{mdf}{title}{%
\def\mdf@@title{#1}
}
\mdfdefinestyle{exercisestyle}{%
middlelinewidth=1.2pt,roundcorner=5pt,linecolor=gray,
apptotikzsetting={\tikzset{mdfbackground/.append style={top color=blue!40, bottom color=white}}},
innertopmargin=1.2\baselineskip,
skipabove={\dimexpr0.5\baselineskip+\topskip\relax},
skipbelow={-1em},
shadow=true,
shadowcolor=blue!35,
needspace=3\baselineskip,
frametitlefont=\sffamily\bfseries,
singleextra={%
\node[titregris,xshift=1cm] at (P-|O) %
{~\mdf@frametitlefont{Exercise~\textnumero\theexercise}~\mdf@@title};
\ifdefempty{\mdf@@exercisepoints}%
{}
{\node[pointstyle,left,xshift=-1cm] at (P)%
{~\mdf@frametitlefont{\mdf@@exercisepoints pt.}~};},%
\ifdefempty{\mdf@@fig}%
{}%
{\path let \p1=(P), \p2=(O) in node[fill=blue!40,circle,inner sep=1pt,font=\color{white}] at (P|-0,0.5*\y2+0.5*\y1) {\mdf@@fig};}%
},
firstextra={%
\node[titregris,xshift=1cm] at (P-|O) %
{~\mdf@frametitlefont{Exercise~\textnumero\theexercise}~~\mdf@@title};
\ifdefempty{\mdf@@exercisepoints }%
{}%
{\node[pointstyle,left,xshift=-1cm] at (P)%
{~\mdf@frametitlefont{\mdf@@exercisepoints points}~};},%
},
}
\newcommand\listmdfname{List of Exercises}
\newcommand\listofmdframed{\section*{\listmdfname}%
\@mkboth{\MakeUppercase\listfigurename}%
{\MakeUppercase\listfigurename}%
\@starttoc{mdf}}
\newenvironment{mythm}[2][]
{\refstepcounter{exercise}\addcontentsline{mdf}{figure}{Exercise~\theexercise~#2}\begin{mdframed}[style=exercisestyle,#1,title=#2]}
{\end{mdframed}}
\makeatother
\begin{document}
\listofmdframed
\begin{mythm}[exercisepoints=10,fig=$\spadesuit$]{Example $E=mc^2$}
\begin{align}
\dot{n} &= u\cos\psi -v\sin\psi \\
\dot{e} &= u\sin\psi + v\cos\psi
\end{align}
For small angles the following approximation can be used:
\begin{align}
\dot{n} &= u -v\delta_\psi \\
\dot{e} &= u\delta_\psi + v
\end{align}
\end{mythm}
\begin{mythm}[exercisepoints=5,fig=$\spadesuit$]{Example $a=b$}
\begin{align}
\dot{n} &= u\cos\psi -v\sin\psi \\
\dot{e} &= u\sin\psi + v\cos\psi
\end{align}
For small angles the following approximation can be used:
\begin{align}
\dot{n} &= u -v\delta_\psi \\
\dot{e} &= u\delta_\psi + v
\end{align}
\end{mythm}
\vspace{0.1cm}
Here is problematic example:
\begin{mythm}[exercisepoints=10,fig=$\spadesuit$]{Example Problematic}
\begin{align}
\dot{n} &= u\cos\psi -v\sin\psi\displaybreak\\
\dot{e} &= u\sin\psi + v\cos\psi
\end{align}
For small angles the following approximation can be used:
\begin{align}
\dot{n} &= u -v\delta_\psi \\
\dot{e} &= u\delta_\psi + v
\end{align}
\end{mythm}
\begin{mythm}[exercisepoints=5,fig=$\spadesuit$]{Example $a=b$}
\begin{align}
\dot{n} &= u\cos\psi -v\sin\psi \\
\dot{e} &= u\sin\psi + v\cos\psi
\end{align}
For small angles the following approximation can be used:
\begin{align}
\dot{n} &= u -v\delta_\psi \\
\dot{e} &= u\delta_\psi + v
\end{align}
\end{mythm}
\end{document}
我使用 LaTeX 内核@starttoc
创建了一个新列表,其行为方式与 LoF、Lot 完全类似;使用的文件扩展名是mdf
(此新列表的信息将写入 fil <name>.mdf
);可以使用 来控制此列表使用的名称\listmdfname
。
环境mythm
有一个可选参数,用于将选项传递给的可选参数mdframed
,还有一个强制参数,该参数将用作新列表中的条目并为环境提供标题mdframed
。
一些额外的评论:
你的代码有
\renewcommand*\theexercise{Exercise \textnumero\arabic{exercise}}
这不是最好的选择,\theexercise
它用于保存计数器的表示,添加Exercise \textnumero
可能会产生不良结果(例如,在交叉引用中)。我在我的代码中更改了这一点。额外的字符串被添加到计数器表示之外。
另外,我在环境中踩了计数器
mythm
(避免了评论中提到的不必要的计数器体操)。如果希望计数器在给定的部分单元中重置,最快的方法是使用(例如,对于章节)
\usepackage{chngcntr} \counterwithin{exercise}{chapter}
(该行\counterwithin
必须出现在计数器定义之后)。
更新:
如果我理解评论中提出的新要求,那么可以对mdframed
具有变量标题的各种环境使用相同的设置;我们的想法是为标题设置一个宏,并让每个环境适当地重新定义标题宏(我\mymdftitle
在下面的例子中调用了这个宏):
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1,T2A]{fontenc}
\usepackage[english,russian]{babel}
\usepackage[a5paper]{geometry}
\usepackage{amsthm,thmtools}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{amsmath,amssymb}
\usetikzlibrary{shadows.blur}
\usetikzlibrary{shapes.symbols}
\usetikzlibrary{shadows,shapes}
\usetikzlibrary{calc}
\usepackage{lipsum}
\newcounter{exercise}
\newcommand\mymdftitle{}
\tikzset{myshadow/.style={ % custom shadow with tikz
opacity=.85,
shadow xshift=0.15,
shadow yshift=-0.15,
shade,
shading=axis,
shading angle=230}
}
\tikzstyle{titregris} =
[draw=gray, line width=1.0pt,%
text=white, rectangle,
right,minimum height=.7cm,
double,
shade,
top color=blue!40,
bottom color=blue!5,
rounded corners=8pt,
opacity=1,
shadow xshift=0.15,
shadow yshift=-0.15,
shade,
shading=axis,
shading angle=30,
drop shadow,
]
\tikzstyle{pointstyle} =
[draw=red, thick, fill=red,%
text=white, rectangle,
right,minimum height=.7cm,
double,
shade,
top color=red,
bottom color=blue!5,
rounded corners=3pt,
drop shadow
]
%\renewcommand*\theexercise{Exercise \textnumero\arabic{exercise}}
\makeatletter
\def\mdf@@exercisepoints{}%new mdframed key:
\define@key{mdf}{exercisepoints}{%
\def\mdf@@exercisepoints{#1}
}
\def\mdf@@fig{}%new mdframed key:
\define@key{mdf}{fig}{%
\def\mdf@@fig{#1}
}
\def\mdf@@title{}%new mdframed key:
\define@key{mdf}{title}{%
\def\mdf@@title{#1}
}
\mdfdefinestyle{exercisestyle}{%
middlelinewidth=1.2pt,
roundcorner=5pt,
linecolor=gray,
apptotikzsetting={\tikzset{mdfbackground/.append style={
top color=blue!40, bottom color=white}}},
innertopmargin=1.2\baselineskip,
skipabove={\dimexpr0.5\baselineskip+\topskip\relax},
skipbelow={-1em},
shadow=true,
shadowcolor=blue!35,
needspace=3\baselineskip,
frametitlefont=\sffamily\bfseries,
singleextra={%
\node[titregris,xshift=1cm] at (P-|O) %
{\mdf@frametitlefont{\mymdftitle}\mdf@@title~};
\ifdefempty{\mdf@@exercisepoints}%
{}
{\node[pointstyle,left,xshift=-1cm] at (P)%
{~\mdf@frametitlefont{\mdf@@exercisepoints pt.}~};},%
\ifdefempty{\mdf@@fig}%
{}%
{\path let \p1=(P), \p2=(O) in node[fill=blue!40,circle,inner sep=1pt,font=\color{white}] at (P|-0,0.5*\y2+0.5*\y1) {\mdf@@fig};}},
firstextra={%
\node[titregris,xshift=1cm] at (P-|O) %
{~\mdf@frametitlefont{\mymdftitle}~~\mdf@@title};
\ifdefempty{\mdf@@exercisepoints }%
{}%
{\node[pointstyle,left,xshift=-1cm] at (P)%
{~\mdf@frametitlefont{\mdf@@exercisepoints points}~};},%
},
}
\newcommand\listmdfname{List of Exercises}
\newcommand\listofmdframed{%
\section*{\listmdfname}%
\@mkboth{\MakeUppercase\listmdfname}{\MakeUppercase\listmdfname}%
\@starttoc{mdf}}
\newenvironment{mythm}[2][]
{\renewcommand\mymdftitle{~Exercise~\textnumero\theexercise~}%
\refstepcounter{exercise}%
\addcontentsline{mdf}{figure}{Exercise~\theexercise~#2}
\begin{mdframed}[style=exercisestyle,#1,title=#2]%
}
{\end{mdframed}}
\newenvironment{myanother}[2][]
{\renewcommand\mymdftitle{~A new title~}%
\begin{mdframed}[style=exercisestyle,#1,title=#2]%
}
{\end{mdframed}}
\makeatother
\begin{document}
\listofmdframed
\begin{mythm}[exercisepoints=10,fig=$\spadesuit$]{Example $E=mc^2$}
\begin{align}
\dot{n} &= u\cos\psi -v\sin\psi \\
\dot{e} &= u\sin\psi + v\cos\psi
\end{align}
For small angles the following approximation can be used:
\begin{align}
\dot{n} &= u -v\delta_\psi \\
\dot{e} &= u\delta_\psi + v
\end{align}
\end{mythm}
\begin{myanother}{Additional Information}
\begin{align}
\dot{n} &= u\cos\psi -v\sin\psi \\
\dot{e} &= u\sin\psi + v\cos\psi
\end{align}
For small angles the following approximation can be used:
\begin{align}
\dot{n} &= u -v\delta_\psi \\
\dot{e} &= u\delta_\psi + v
\end{align}
\end{myanother}
\end{document}