我找到了一种获得可破坏盒子的方法,使用阿拉伯语的多语种和 Tikz 包,但我遇到了两个问题......
1)Tikz 的 leftmargin 和 rightmargin 命令对盒子没有影响...有一个包决定盒子的宽度...哪一个以及我该如何保留它?
2) 我想在框架标题框中为某些框架添加标题(每个框架都不同)(此处为示例)。我该如何声明这样的环境?
谢谢你的帮助
下面是我的包的一个简单示例(不用担心从右到左书写的文本!!)
\documentclass[14pt,a4paper]{extbook}%{article}%
\usepackage{amsmath,amssymb}
\usepackage[framemethod=TikZ]{mdframed}
%\usepackage[dvips]{graphicx}
\usepackage{boxedminipage}
\usepackage{slashbox}
\usepackage{titlesec}
\usepackage{xcolor}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{enumitem}
\usepackage{minitoc}
\usepackage{rotating}
\usepackage{fmultico}
\setlength{\columnseprule}{0.1pt}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic, AutoFakeSlant=-0.02]{Amiri}
\setsansfont[Script=Arabic,Scale=1.5]{Amiri}
\tikzstyle{titleframe} =
[draw=black, thick, scale=.7, fill=white,%
line width=0.1pt, text=black, rectangle,
left, minimum height=.5cm]
\newcounter{example}
\renewcommand*\theexample{Example~\arabic{section}.\arabic{example}}
\makeatletter
\mdfdefinestyle{examplestyle}{%
outerlinewidth=1em,%
outerlinecolor=white,%
leftmargin=-1em,%
rightmargin=-1em,%
middlelinewidth=1.2pt,%
% roundcorner=5pt,%
linecolor=gray!20,%
backgroundcolor=white,%
innertopmargin=1.2\baselineskip,
% skipabove={\dimexpr0.5\baselineskip+\topskip\relax},
skipabove={\dimexpr1\baselineskip\relax},
skipbelow={0em},
needspace=3\baselineskip,
frametitlefont=\sffamily\bfseries,
settings={\global\stepcounter{example}},
firstextra={%
\node[titleframe,xshift=-1cm] at (P-|P) %
{\RL{~{\mdf@frametitlefont{\theexample}}~}};},%
singleextra={%
% \node[titleframe,xshift=1cm] at (P-|O) %
\node[titleframe,xshift=-1cm] at (P-|P) %
{~{\mdf@frametitlefont{\theexample}}~};}
}
\makeatother
\newenvironment{example}%
{\begin{mdframed}[style=examplestyle]}{\end{mdframed}}
\begin{document}
\begin{example}
To calculate the horizontal position the kinematic differential
equations are needed:
\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{example}
\end{document}
答案1
有了tcolorbox
。仍有改进的空间,但这应该作为一个起点。
\documentclass[14pt,a4paper]{extbook}%{article}%
\usepackage{amsmath,amssymb}
\usepackage[most]{tcolorbox}
%\usepackage[dvips]{graphicx}
\usepackage{boxedminipage}
\usepackage{slashbox}
\usepackage{titlesec}
\usepackage{enumitem}
\usepackage{minitoc}
\usepackage{rotating}
\usepackage{fmultico}
\setlength{\columnseprule}{0.1pt}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic, AutoFakeSlant=-0.02]{Amiri}
\setsansfont[Script=Arabic,Scale=1.5]{Amiri}
\newcounter{example}
\renewcommand*\theexample{Example~\arabic{section}.\arabic{example}}
\newtcolorbox[use counter=example]{example}[3][]{%
enhanced,
colback=blue!10!white,
colframe=orange,
top=6mm,
enlarge top by=\baselineskip/2+1mm,
enlarge top at break by=0mm,pad at break=2mm,
fontupper=\normalsize,
label={#3},
overlay unbroken and first={%
\node[rectangle,rounded corners,draw=black,fill=blue!20!white,
inner sep=1mm,anchor=east,font=\small,text width=0.5\textwidth]
at ([xshift=-1cm]frame.north east)
{\strut\RL{\textbf{Example \thetcbcounter: #2}}};},
breakable,
width=0.9\textwidth, %%% change the width here.
#1}%
\begin{document}
\noindent
\begin{example}{My title goes long and long and long}{ex:first} %% last one is label
To calculate the horizontal position the kinematic differential
equations are needed:
\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{example}
\end{document}