描述
\newmdtheoremenv{definition}{Definition}
包装用盒子mdframed
创造一个环境。definition
\mydefinition{left}{right}
使用给定的文本创建彩色的 tikz 节点
- 节点的大小可以在定义中改变
代码
\documentclass{article}
\usepackage{mdframed}
\usepackage{tikz}
\usetikzlibrary{positioning}
\newmdtheoremenv{definition}{Definition}
\newcommand{\mydefinition}[2]{%
\hfill
\begin{tikzpicture}[node distance=0pt]
\node[fill=yellow, text width=30mm, align=right] (a) {\strut#1};
\node[right=of a.north east, anchor=north west] (eq) {\strut=};
\node[fill=red, text width=70mm, right=of eq.north east, anchor=north west] (b) {\strut#2};
\end{tikzpicture}
}
\begin{document}
\begin{definition}
\mydefinition{Ideal $oe$}{abclian subgroup such that $\forall a \in I$ and $r \in R : ra \in I$}
\end{definition}
\begin{definition}
\mydefinition{and a very long text on the left side is also possible}{abclian subgroup such that $\forall a \in I and r \in R : ra \in I$}
\end{definition}
\end{document}
结果