您能帮我在环境中添加第二个框架标题mdframed
吗?它是用于引用的,它应该比定义的第一个标题向右移动 15pt / 20pt 左右。因此,在下面的代码中应该有类似这样的内容
\begin{df}[mytitle = {Pythagoraen Theorem}{\cite[page 6]{test}}]
This is a definition.
\end{df}
我猜我需要在 makeatother 环境中添加一些东西。但我不知道具体该怎么做。你能帮我吗?
\documentclass{scrreprt}
\usepackage[framemethod=tikz]{mdframed}
\usetikzlibrary{calc}
\usepackage{amsthm}
\newcounter{mydef}[chapter]
\renewcommand\themydef{\arabic{chapter}.\arabic{mydef}}
\makeatletter
\def\mdf@mytitle{}
\define@key{mdf}{mytitle}{%
\def\mdf@mytitle{#1}}
\mdf@do@stringoption{digressiontitle=={Digression}}
\tikzset{
excursus line/.style={%
line width=2pt,
draw=gray!40,
rounded corners=2ex,
},
excursus head/.style={%
fill=white,
font=\bfseries\sffamily,
text=blue!80,
anchor=base west,
},
}
\mdfdefinestyle{digressionarrows}{%
extra={\stepcounter{mydef}},%
singleextra={%
\path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
\path let \p1=(Q), \p2=(O) in (\x1,{(\y1-\y2)/2}) coordinate (M);
\path [excursus line]
($(O)+(5em,0ex)$) -| (M) |- %
($(Q)+(30em,0ex)$);
%\node at ($(M)$) {M};
%\node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {Digression};},
\ifx\empty\mdf@mytitle\empty
\node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {\mdf@digressiontitle~\themydef};
\else
\node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {\mdf@digressiontitle~\themydef\space(\mdf@mytitle):};
\fi},
firstextra={%
\path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
\path [excursus arrow,-to]
(O) |- %
($(Q)+(12em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
++(23em,2ex);
%\node [excursus head] at ($(Q)+(2.5em,-2pt)$) {Digression};},
\ifx\empty\mdf@mytitle\empty
\node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {\mdf@digressiontitle~\themydef};
\else
\node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {\mdf@digressiontitle~\themydef\space(\mdf@mytitle):};
\fi},
secondextra={%
\path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
\path [excursus arrow,round cap-]
($(O)+(5em,0ex)$) -| (Q);},
middleextra={%
\path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
\path [excursus arrow]
(O) -- (Q);},
middlelinewidth=2.5em,middlelinecolor=white,
hidealllines=true,topline=true,
innertopmargin=0.5ex,
innerbottommargin=2.5ex,
innerrightmargin=2pt,
innerleftmargin=2ex,
skipabove=0.87\baselineskip,
skipbelow=0.62\baselineskip,
}
\makeatother
\newmdenv[style=digressionarrows,digressiontitle=Definition]{df}
\newtheorem{thm}[mydef]{Theorem}
\newtheorem{prop}[mydef]{Proposition}
\begin{document}
\chapter{Chapter}
\section{test}
\begin{df}[mytitle={Pythagorean Theorem, See~\cite[page 6]{test}}]
test text
\end{df}
\begin{thm}[See~\cite{test}]
test theorem
\end{thm}
\begin{prop}
test proposition
\end{prop}
\begin{thebibliography}{9}
\bibitem{test} Test
\end{thebibliography}
\end{document}
答案1
这不是一个优雅的解决方案,但它确实有效。我只是定义了一个新的引用命令,以便引用在框架标题中稍微靠右一点。所以它是这样的:
代码
\documentclass{scrreprt}
\usepackage[framemethod=tikz]{mdframed}
\usetikzlibrary{calc}
\usepackage{amsthm}
\newcounter{mydef}[chapter]
\renewcommand\themydef{\arabic{chapter}.\arabic{mydef}}
\makeatletter
\def\mdf@mytitle{}
\define@key{mdf}{mytitle}{%
\def\mdf@mytitle{#1}}
\mdf@do@stringoption{digressiontitle=={Digression}}
\tikzset{
excursus line/.style={%
line width=2pt,
draw=gray!40,
rounded corners=2ex,
},
excursus head/.style={%
fill=white,
font=\bfseries\sffamily,
text=blue!80,
anchor=base west,
},
}
\mdfdefinestyle{digressionarrows}{%
extra={\stepcounter{mydef}},%
singleextra={%
\path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
\path let \p1=(Q), \p2=(O) in (\x1,{(\y1-\y2)/2}) coordinate (M);
\path [excursus line]
($(O)+(5em,0ex)$) -| (M) |- %
($(Q)+(30em,0ex)$);
%\node at ($(M)$) {M};
%\node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {Digression};},
\ifx\empty\mdf@mytitle\empty
\node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {\mdf@digressiontitle~\themydef};
\else
\node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {\mdf@digressiontitle~\themydef\space(\mdf@mytitle):};
\fi},
firstextra={%
\path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
\path [excursus arrow,-to]
(O) |- %
($(Q)+(12em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
++(23em,2ex);
%\node [excursus head] at ($(Q)+(2.5em,-2pt)$) {Digression};},
\ifx\empty\mdf@mytitle\empty
\node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {\mdf@digressiontitle~\themydef};
\else
\node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {\mdf@digressiontitle~\themydef\space(\mdf@mytitle):};
\fi},
secondextra={%
\path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
\path [excursus arrow,round cap-]
($(O)+(5em,0ex)$) -| (Q);},
middleextra={%
\path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
\path [excursus arrow]
(O) -- (Q);},
middlelinewidth=2.5em,middlelinecolor=white,
hidealllines=true,topline=true,
innertopmargin=0.5ex,
innerbottommargin=2.5ex,
innerrightmargin=2pt,
innerleftmargin=2ex,
skipabove=0.87\baselineskip,
skipbelow=0.62\baselineskip,
}
\makeatother
\newmdenv[style=digressionarrows,digressiontitle=Definition]{df}
\newtheorem{thm}[mydef]{Theorem}
\newtheorem{prop}[mydef]{Proposition}
\newcommand{\mycite}[2]{\black{\hspace{30pt}\cite[#1]{#2
\begin{document}
\chapter{Chapter}
\section{test}
\begin{df}[mytitle={Pythagorean Theorem \mycite{Definition 3}{test}}}]
test text
\end{df}
\begin{thm}[See~\cite{test}]
test theorem
\end{thm}
\begin{prop}
test proposition
\end{prop}
\begin{thebibliography}{9}
\bibitem{test} Test
\end{thebibliography}
\end{document}