2014年5月1日木曜日

mdframedを用いた定理環境の修飾(platex+dvipdfmx, tikz)

追記:2016/04/19 定理環境をmdframedを使ったものからtcolorboxを使ったものに変更しました。

以前にplatexではmdframedでtikzを使った描画はうまくいかない風なことを書きましたが,あれはウソでした。すみません。

mdframedパッケージを読み込む前に,graphicxパッケージにdvipdfmxオプションを付けて読み込んでおけば使えました。

前回記事にした定理環境では,定理の番号に章番号や節番号を付けて出力したり参照したりするときに不便なため,書き直しをしました。次のように記述しておけば,platex+dvipdfmxできちんとした出力が得られます。
\documentclass[a4paper,10pt,papersize]{jsarticle}
\usepackage{amsmath,amssymb,mathrsfs}
\usepackage{etoolbox}
\usepackage[svgnames]{xcolor}
\usepackage[dvipdfmx]{graphicx}
\usepackage[framemethod=tikz]{mdframed}

\newcounter{theo}
\numberwithin{theo}{section}
\newenvironment{theo}[1][]{%
\refstepcounter{theo}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!20]
{\strut 定理~\thetheo.};}}}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!20]
{\strut 定理~\thetheo.~#1};}}%
}%
\mdfsetup{innertopmargin=5pt,linecolor=blue!20,%
linewidth=2pt,topline=true,
frametitleaboveskip=\dimexpr-\ht\strutbox\relax,}
\begin{mdframed}[]\relax%
}{\end{mdframed}} 


\begin{document}

\section{Riemann積分}
\begin{theo}[Riemann積分の線型性]
\label{theo:riemann}
$\mathscr{R}(I)$を$\mathbb{R}^n$の有界閉区間$I$上でRiemann可積分な実数値関数全体
 の集合とする.$\mathscr{R}(I)$は実ベクトル空間であり,$I$上の積分は
$\mathscr{R}(I)$から$\mathbb{R}$への線型写像である.即ち
\begin{equation}
 f, g\in \mathscr{R}(I),\ c\in \mathbb{R}\text{ならば}
f+g\in \mathscr{R}(I),\ cf\in \mathscr{R}(I)
\end{equation}
であり,なおかつ
  \begin{gather}
  \int_I (f+g)(x)\, dx
 =\int_I f(x)\, dx + \int_I g(x)\, dx, \\
  \int_I cf(x)\, dx 
 = c\int_I f(x)\, dx
 \end{gather}
が成り立つ.
\end{theo}

定理\,\ref{theo:riemann}は凄い!

\end{document}


これを使って数学ノートのプリアンプルを書き換えました。現在は定理環境が次のような体裁になっています。