dotfiles/texmf/tex/latex/frank_tex/boiboites.sty
2016-01-22 17:39:58 +01:00

78 lines
2.5 KiB
TeX

\RequirePackage{xkeyval}
\RequirePackage{tikz}
\RequirePackage{amssymb}
\define@key{boxedtheorem}{titlecolor}{\def\titlecolor{#1}}
\define@key{boxedtheorem}{titlebackground}{\def\titlebackground{#1}}
\define@key{boxedtheorem}{background}{\def\background{#1}}
\define@key{boxedtheorem}{titleboxcolor}{\def\titleboxcolor{#1}}
\define@key{boxedtheorem}{boxcolor}{\def\boxcolor{#1}}
\define@key{boxedtheorem}{thcounter}{\def\thcounter{#1}}
\define@key{boxedtheorem}{size}{\def\size{#1}}
\presetkeys{boxedtheorem}{titlecolor = black, titlebackground = white, background = white,%
titleboxcolor = black, boxcolor = black, thcounter=, size = .9\textwidth}{}
\newcommand{\couleurs}[1][]{%
\setkeys{boxedtheorem}{#1}
\tikzstyle{fancytitle} =[draw=\titleboxcolor, rounded corners, fill=\titlebackground,
text= \titlecolor]
\tikzstyle{mybox} = [draw=\boxcolor, fill=\background, very thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt]
}
%Commande générique pour faire un joli encadré
\newsavebox{\boiboite}
\newcommand{\titre}{Titre}
\newenvironment{boite}[2][]%
{%
\renewcommand{\titre}{#2}
\couleurs[#1]
\begin{lrbox}{\boiboite}%
\begin{minipage}[!h]{\size}
}%
{%
\end{minipage}
\end{lrbox}
\begin{center}
\begin{tikzpicture}
\node [mybox] (box){\usebox{\boiboite}};
\node[fancytitle, right=10pt] at (box.north west) {\titre};
\end{tikzpicture}
\end{center}
}
\newcommand{\newboxedtheorem}[4][]{%
\couleurs[#1]
\@ifnotempty{#4}{%
\@ifundefined{the#4}{\@ifundefined{\thcounter}{\newcounter{#4}}{%
\newcounter{#4}[\thcounter ] } } { }%
}
\newenvironment{#2}[1][]{%
\@ifnotempty{#4}{\refstepcounter{#4}}
\begin{boite}[#1]{\textbf{#3\@ifnotempty{#4}{ \csname the#4\endcsname}}\@ifnotempty{##1}{
(##1)}\textbf{.}}
}%
{%
\end{boite}
}
}
%http://snouffy.free.fr/blog-fr/index.php/post/2009/09/30/Des-jolies-boites-en-LaTeX-pour-encadrer-les-th%C3%A9or%C3%A8mes
%\newboxedtheorem[boxcolor=orange, background=blue!5, titlebackground=blue!20,
%titleboxcolor = black]{theo}{Théorème}{test}
%%%%Document
% \begin{theo}[Loi des grands nombres]
% Soit $(X_n)_{n\in \mathbb{N}}$ une suite de variables aléatoires réelles
% indépendantes identiquement distribuées telles que $X_1 \in L^1$. Alors :
% $$\frac{1}{n} \sum_{i=1}^n X_i \overset{\textnormal{p.s.}}{\longrightarrow}
% \mathbb{E} (X_1) .$$
% \end{theo}