latex-homework/jl-cours/fixes.tex

137 lines
5.0 KiB
TeX

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% FIXES
%
%
%% Fix error from KOMA-Script scrartcl class.
%%
\DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}
%% Fix for mdframed package see :
%% http://tex.stackexchange.com/questions/179790/mdframed-how-to-change-the-separator-between-the-label-and-the-title-of-a-non-n#179794
%%
\DeclareDocumentCommand{\mdtheorem}{ O{} m o m o }%
{\ifcsdef{#2}%
{\mdf@PackageWarning{Environment #2 already exits\MessageBreak}}%
{%
\IfNoValueTF {#3}%
{%#3 not given -- number relationship
\IfNoValueTF {#5}%
{%#3+#5 not given
\@definecounter{#2}%
\expandafter\xdef\csname the#2\endcsname{\@thmcounter{#2}}%
\newenvironment{#2}[1][]{%
\refstepcounter{#2}%
\ifstrempty{##1}%
{\let\@temptitle\relax}%
{%
\def\@temptitle{\mdf@theoremseparator%
\mdf@theoremspace%
\mdf@theoremtitlefont%
##1}%
\mdf@thm@caption{#2}{{#4}{\csname the#2\endcsname}{##1}}%
}%
\begin{mdframed}[#1,frametitle={\strut#4\ \csname the#2\endcsname%
\@temptitle}]}%
{\end{mdframed}}%
\newenvironment{#2*}[1][]{%
\ifstrempty{##1}{\let\@temptitle\relax}{\def\@temptitle{\mdf@theoremseparator\ ##1}}% <- the problem was here
\begin{mdframed}[#1,frametitle={\strut#4\@temptitle}]}%
{\end{mdframed}}%
}%
{%#5 given -- reset counter
\@definecounter{#2}\@newctr{#2}[#5]%
\expandafter\xdef\csname the#2\endcsname{\@thmcounter{#2}}%
\expandafter\xdef\csname the#2\endcsname{%
\expandafter\noexpand\csname the#5\endcsname \@thmcountersep%
\@thmcounter{#2}}%
\newenvironment{#2}[1][]{%
\refstepcounter{#2}%
\ifstrempty{##1}%
{\let\@temptitle\relax}%
{%
\def\@temptitle{\mdf@theoremseparator%
\mdf@theoremspace%
\mdf@theoremtitlefont%
##1}%
\mdf@thm@caption{#2}{{#4}{\csname the#2\endcsname}{##1}}%
}
\begin{mdframed}[#1,frametitle={\strut#4\ \csname the#2\endcsname%
\@temptitle}]}%
{\end{mdframed}}%
\newenvironment{#2*}[1][]{%
\ifstrempty{##1}%
{\let\@temptitle\relax}%
{%
\def\@temptitle{\mdf@theoremseparator%
\mdf@theoremspace%
\mdf@theoremtitlefont%
##1}%
\mdf@thm@caption{#2}{{#4}{\csname the#2\endcsname}{##1}}%
}%
\begin{mdframed}[#1,frametitle={\strut#4\@temptitle}]}%
{\end{mdframed}}%
}%
}%
{%#3 given -- number relationship
\global\@namedef{the#2}{\@nameuse{the#3}}%
\newenvironment{#2}[1][]{%
\refstepcounter{#3}%
\ifstrempty{##1}%
{\let\@temptitle\relax}%
{%
\def\@temptitle{\mdf@theoremseparator%
\mdf@theoremspace%
\mdf@theoremtitlefont%
##1}%
\mdf@thm@caption{#2}{{#4}{\csname the#2\endcsname}{##1}}%
}
\begin{mdframed}[#1,frametitle={\strut#4\ \csname the#2\endcsname%
\@temptitle}]}%
{\end{mdframed}}%
\newenvironment{#2*}[1][]{%
\ifstrempty{##1}{\let\@temptitle\relax}{\def\@temptitle{:\ ##1}}%
\begin{mdframed}[#1,frametitle={\strut#4\@temptitle}]}%
{\end{mdframed}}%
}%
}%
}
%% From chingatome.fr
%% to allow some code to be compiled and avoid me to recode some macros
%%
\newbox\dboite%
\newbox\gboite%
\newcommand{\centredeuxlignes}[3][t]{\if t#1\normalbaselineskip=0pt\normallineskip=2pt\normallineskiplimit=10pt\else\normalbaselineskip=0pt\normallineskip=#1pt\normallineskiplimit=10pt\fi%
\setbox\gboite\hbox{#2}%
\setbox\dboite\hbox{#3}%
\ifdim\wd\gboite<\wd\dboite%
$\vcenter{\normalbaselines\hbox to\wd\dboite{\null\hfill#2\hfill\null}\hbox{\null\hfill#3\hfill\null}}$%
\else%
\hbox{$\vcenter{\normalbaselines\hbox{\null\hfill#2\hfill\null}\hbox to \wd\gboite{\null\hfill#3\hfill\null}}$}%
\fi}
\newcommand{\boite}[2][]{%
\edef\x@x{\the\@listdepth}%
\edef\y@y{\the\@enumdepth}%
{%
%% Sauvegarde valeur
\@listdepth0%
\@enumdepth=0%
%% Macro
\def\@tmp@a{#1}%
\@totalleftmargin=0cm%
\dimen0\linewidth\advance\dimen0-2\fboxsep\advance\dimen0-2\fboxrule%
\ifx \@tmp@a\@empty\setbox0\vbox{\tolerance10000%
\linewidth\dimen0\hsize\dimen0 #2}\else\setbox0\vtop{\tolerance10000\linewidth\dimen0\hsize\dimen0 #2}\fi%
\fcolorbox{black}{lightgray}{\box0}}%
\global\@listdepth=\x@x%
%\global\@enumdepth=\y@y%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%