我正在尝试创建一个新的环境,mdframed
但是我尝试定义的某些选项不起作用。
以下是代码:
\documentclass[11pt, twosided]{book}
\usepackage[T1]{fontenc}
\usepackage[framemethod]{mdframed}
\usepackage{setspace}
\usepackage{xcolor}
\mdfdefinestyle{mdfexample1}{leftmargin=1cm,rightmargin=2cm,%
innerleftmargin=1cm,innerrightmargin=1cm,roundcorner=10pt}
\newmdenv[skipabove=15pt,
skipbelow=7pt,
rightline=true,
leftline=true,
topline=true,
bottomline=true,
linecolor=green,
backgroundcolor=green!10,
innerleftmargin=15pt,
innerrightmargin=15pt,
innertopmargin=15pt,
leftmargin=2cm,
rightmargin=2cm,
linewidth=2pt,
innerbottommargin=15pt,
roundcorner=10pt]{mBox}
\newenvironment{caixa}
{\begin{mBox}\onehalfspacing\small\color{blue}\ttfamily}{\end{mBox}}
\begin{document}
\begin{caixa}
\begin{itemize}
\item Parque 1
\item Parque 2
\end{itemize}
\end{caixa}
\begin{mdframed}[style=mdfexample1]
In any right triangle, the area of the square whose side is the hypotenuse
is equal to the sum of the areas of the squares whose sides are the two
legs.
\end{mdframed}
\end{document}
如您所见,它不尊重我定义的几个选项,例如roundcorners
和。有人知道出了什么问题leftmargin
吗rightmargin
?提前谢谢您!
答案1
必须framemethod
指定为tikz
,而不是空framemethod
键。
如果在twoside
模式下工作,应使用outermargin
和选项而不是和。innermargin
rightmargin
leftmargin
\documentclass[11pt, twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{setspace}
\usepackage{xcolor}
\usepackage[framemethod=tikz]{mdframed}
\colorlet{azul}{blue}
\makeatletter % The code checks for twoside or oneside options
\if@twoside
\mdfdefinestyle{mdfexample1}{
innermargin=1cm,
outermargin=2cm,%
innerleftmargin=1cm,
innerrightmargin=1cm,
roundcorner=10pt}
\else
\mdfdefinestyle{mdfexample1}{
leftmargin=1cm,
rightmargin=2cm,%
innerleftmargin=1cm,
innerrightmargin=1cm,
roundcorner=10pt}
\fi
\makeatother
\newmdenv[skipabove=15pt,
skipbelow=7pt,
rightline=true,
leftline=true,
topline=true,
bottomline=true,
linecolor=green,
backgroundcolor=green!10,
innerleftmargin=15pt,
innerrightmargin=15pt,
innertopmargin=15pt,
leftmargin=2cm,
rightmargin=2cm,
linewidth=2pt,
innerbottommargin=15pt,
roundcorner=10pt]{mBox}
\newenvironment{caixa}
{\begin{mBox}\onehalfspacing\small\color{azul}\ttfamily}{\end{mBox}}
\begin{document}
\begin{caixa}
\begin{itemize}
\item Parque 1
\item Parque 2
\end{itemize}
\end{caixa}
\begin{mdframed}[style=mdfexample1]
In any right triangle, the area of the square whose side is the hypotenuse
is equal to the sum of the areas of the squares whose sides are the two
legs.
\end{mdframed}
\end{document}