bclogo.sty option nobreak compatible avec mdframed 0.6a
[bclogo.git] / dev / latex / bclogo.sty
1 \NeedsTeXFormat{LaTeX2e}%
2 \def\PackageName{bclogo}%
3 \def\fileversion{v3.0}%
4 \def\filedate{2011/10/01}%
5 \ProvidesPackage{bclogo}[\filedate\space\fileversion]%
6 %
7 % Extensions a charger
8 \RequirePackage{xkeyval,ifthen}%
9 \RequirePackage{graphicx}%
10 \RequirePackage{mdframed}%
11 %
12 %% Les options globales du package sont au nombre de 2: tikz ou pstricks
13 \newif\ifbclogotikz%
14 \newif\ifbclogoblur%
15 \define@key{bclogo.sty}{tikz}[]{\bclogotikztrue}%
16 \define@key{bclogo.sty}{pstricks}[]{\bclogotikzfalse}%
17 \define@key{bclogo.sty}{blur}[]{\bclogoblurtrue}%
18 %
19 % quelques dimensions
20 \newlength{\bc@invboxh}\newlength{\bc@invboxd}%
21 \newlength{\bc@titleLength}%
22 \newlength{\logowidth}%
23 \newlength{\bc@mdfboxwidth}%
24 \newlength{\bc@mdfboxheight}%
25 %\newlength{\bc@mdf@ymargin@length}
26 %
27 \setlength{\logowidth}{17pt}%
28 \ProcessOptionsX%
29 %
30 \ifbclogotikz%
31         \RequirePackage{tikz}%
32         \usetikzlibrary{shadows}% pour l'ombre
33         \usetikzlibrary{decorations.pathmorphing}% pour la barre ondulee
34         \def\bc@mdf@style{1}%
35         \input{bclogoMdframedTikz}%
36 \else%
37         \RequirePackage{pstricks}%
38         \RequirePackage{pst-grad}%
39         \RequirePackage{pst-coil}% pour la barre ondulee
40         \ifbclogoblur%
41                 \RequirePackage{pst-blur}%
42                 \let\pagecolorOLD\pagecolor% modification pour sauvegarde de la couleur du fond
43                 \def\pagecolor#1{\gdef\psx@blurbg{#1}\pagecolorOLD{#1}}%suppose l'utilisation: \pagecolor{couleur}
44         \fi%
45         \def\bc@mdf@style{3}%
46         \input{bclogoMdframedPst}%
47 \fi%
48 \edef\Gin@extensions{.mps,\Gin@extensions}%
49 \RequirePackage{ifpdf}%
50 \ifpdf\relax\else\DeclareGraphicsRule{mps}{eps}{*}{}\fi%
51 %
52 % les symboles
53 % ==============================================================================
54 % la fleur
55 \newcommand\bcfleur{\includegraphics[width=\logowidth]{bc-fleur}}%
56 % une note (Thomas Labarussias)
57 \newcommand\bcnote{\includegraphics[width=\logowidth]{bc-note}}%
58 % panneau chantier (Jean-Michel Sarlat)
59 \newcommand\bcpanchant{\includegraphics[width=\logowidth]{bc-aux-301}}%
60 % ours
61 %\newcommand\bcours{\begingroup\input{bc-ours.tex}\endgroup}
62 \newcommand\bcours{\includegraphics[width=\logowidth]{bc-ours}}%
63 % etoile
64 %\newcommand\bcetoile{\begingroup\input{bc-etoile.tex}\endgroup}
65 \newcommand\bcetoile{\includegraphics[width=\logowidth]{bc-etoile}}%
66 % attention
67 %\newcommand\bcattention{\begingroup\input{bc-attention.tex}\endgroup}
68 \newcommand\bcattention{\includegraphics[width=\logowidth]{bc-attention}}%
69 % attention P.Fradin
70 \newcommand\bctakecare{\includegraphics[width=\logowidth]{bc-takecare}}%
71 % lampe P.Fradin
72 \newcommand\bclampe{\includegraphics[width=\logowidth]{bc-lampe}}%
73 % coeur
74 \newcommand\bccoeur{\includegraphics[width=\logowidth]{bc-coeur}}%
75 % ornement (tire du site http://openclipart.org )
76 \newcommand\bcorne{\includegraphics[width=\logowidth]{bc-orne}}%
77 % danger (Francois)
78 \newcommand\bcdanger{\includegraphics[width=\logowidth]{bc-danger}}%
79 % smiley bonne humeur (Francois)
80 \newcommand\bcsmbh{\includegraphics[width=\logowidth]{bc-smiley-bonnehumeur}}%
81 % smiley bonne humeur (Francois)
82 \newcommand\bcsmmh{\includegraphics[width=\logowidth]{bc-smiley-mauvaisehumeur}}%
83 % le trefle
84 \newcommand\bctrefle{\includegraphics[width=\logowidth]{bc-trefle}}%
85 % le livre
86 \newcommand\bcbook{\includegraphics[width=\logowidth]{bc-book}}%
87 % point d'interrogation
88 \newcommand\bcquestion{\includegraphics[width=\logowidth]{bc-inter}}%
89 % crayon anne-sophie philippe
90 \newcommand\bccrayon{\includegraphics[width=\logowidth]{bc-crayon}}%
91 % info (thomas labarrussias)
92 \newcommand\bcinfo{\includegraphics[width=\logowidth]{bc-info}}%
93 % plume
94 \newcommand\bcplume{\includegraphics[width=\logowidth]{bc-plume}}%
95 % le pic LaTeX
96 \newcommand\bcspadesuit{{\centering \huge $\spadesuit$}}%
97 % logos Alphonse Capriani
98 \newcommand\bcbombe{\includegraphics[width=\logowidth]{bc-bombe}}%
99 \newcommand\bccube{\includegraphics[width=\logowidth]{bc-cube}}%
100 \newcommand\bcdallemagne{\includegraphics[width=\logowidth]{bc-dallemagne}}%
101 \newcommand\bcdautriche{\includegraphics[width=\logowidth]{bc-dautriche}}%
102 \newcommand\bcdbelgique{\includegraphics[width=\logowidth]{bc-dbelgique}}%
103 \newcommand\bcdbulgarie{\includegraphics[width=\logowidth]{bc-dbulgarie}}%
104 \newcommand\bcdfrance{\includegraphics[width=\logowidth]{bc-dfrance}}%
105 \newcommand\bcditalie{\includegraphics[width=\logowidth]{bc-ditalie}}%
106 \newcommand\bcdluxembourg{\includegraphics[width=\logowidth]{bc-dluxembourg}}%
107 \newcommand\bcdpaysbas{\includegraphics[width=\logowidth]{bc-dpaysbas}}%
108 \newcommand\bcdodecaedre{\includegraphics[width=\logowidth]{bc-dodecaedre}}%
109 \newcommand\bceclaircie{\includegraphics[width=\logowidth]{bc-eclaircie}}%
110 \newcommand\bcicosaedre{\includegraphics[width=\logowidth]{bc-icosaedre}}%
111 \newcommand\bcinterdit{\includegraphics[width=\logowidth]{bc-interdit}}%
112 \newcommand\bcneige{\includegraphics[width=\logowidth]{bc-neige}}%
113 \newcommand\bcoctaedre{\includegraphics[width=\logowidth]{bc-octaedre}}%
114 \newcommand\bcpluie{\includegraphics[width=\logowidth]{bc-pluie}}%
115 \newcommand\bcpoisson{\includegraphics[width=\logowidth]{bc-poisson}}%
116 \newcommand\bcsoleil{\includegraphics[width=\logowidth]{bc-soleil}}%
117 \newcommand\bcstop{\includegraphics[width=\logowidth]{bc-stop}}%
118 \newcommand\bctetraedre{\includegraphics[width=\logowidth]{bc-tetraedre}}%
119 \newcommand\bccalendrier{\includegraphics[width=\logowidth]{bc-calendrier}}%
120 \newcommand\bchorloge{\includegraphics[width=\logowidth]{bc-horloge}}%
121 \newcommand\bcyin{\includegraphics[width=\logowidth]{bc-yin}}%
122 \newcommand\bcrosevents{\includegraphics[width=\logowidth]{bc-rosevents}}%
123 % fin alphonse
124 % Vincent Pantaloni route glissante
125 \newcommand\bcdz{\includegraphics[width=\logowidth]{bc-dz}}%
126 % François Pétiard
127 \newcommand\bcvelo{\includegraphics[width=\logowidth]{bc-velo}}%
128 \newcommand\bcoeil{\includegraphics[width=\logowidth]{bc-oeil}}%
129 \newcommand\bcpeaceandlove{\includegraphics[width=\logowidth]{bc-peaceandlove}}%
130 \newcommand\bcnucleaire{\includegraphics[width=\logowidth]{bc-nucleaire}}%
131 \newcommand\bcfemme{\includegraphics[width=\logowidth]{bc-femme}}%
132 \newcommand\bchomme{\includegraphics[width=\logowidth]{bc-homme}}%
133 \newcommand\bcloupe{\includegraphics[width=\logowidth]{bc-loupe}}%
134 \newcommand\bcrecyclage{\includegraphics[width=\logowidth]{bc-recyclage}}%
135 \newcommand\bcvaletcoeur{\includegraphics[width=\logowidth]{bc-valetcoeur}}%
136 \newcommand\bccle{\includegraphics[width=\logowidth]{bc-cle}}%
137 \newcommand\bcclefa{\includegraphics[width=\logowidth]{bc-clefa}}%
138 \newcommand\bcclesol{\includegraphics[width=\logowidth]{bc-clesol}}%
139 \newcommand\bcfeujaune{\includegraphics[width=\logowidth]{bc-feujaune}}%
140 \newcommand\bcfeurouge{\includegraphics[width=\logowidth]{bc-feurouge}}%
141 \newcommand\bcfeutricolore{\includegraphics[width=\logowidth]{bc-feutricolore}}%
142 \newcommand\bcfeuvert{\includegraphics[width=\logowidth]{bc-feuvert}}%
143 \newcommand\bcoutil{\includegraphics[width=\logowidth]{bc-outil}}%
144 \newcommand\bctrombone{\includegraphics[width=\logowidth]{bc-trombone}}%
145 % fin François
146 % =========================== La fonction listable =============================
147 %
148 \newcommand{\titrebclogo}{Liste des \texttt{bclogo}}%
149 \newcommand\bccaption[1]{\addcontentsline{bcl}{bclogo}{#1}}%
150 \newcommand\listofbclogo{\section*{\titrebclogo}\@starttoc{bcl}}%
151 \newcommand\l@bclogo[2]{\par\noindent #1,~\textit{page~#2}}%
152 \newcounter{bclogocompteur} % idee de Francois Petiard
153 %
154 % ======================================= les keys =============================
155 %
156 \newlength{\bcval@epBarre}% on definit une longueur : l'epaisseur de la barre en point
157 \newlength{\bcval@framesep}% on definit une longueur : l'epaisseur de la marge en point
158 \newlength{\bcval@tailleOndu}% on definit une longueur : taille d'une ondulation
159 \newlength{\bcval@borderWidth}% on definit une longueur : epaisseur du bord
160 \newlength{\bcval@margeG}% on definit une longueur : marge gauche avant la boîte
161 \newlength{\bcval@margeD}% on definit une longueur : marge droite après la boîte
162 \define@key{bclogo}{logo}[\bcfleur]{\def\bcval@logo{#1}}%
163 \define@key{bclogo}{couleur}[white]{\def\bcval@couleur{#1}}%
164 \define@key{bclogo}{arrondi}[0]{\def\bcval@arrondi{#1}}%
165 \define@key{bclogo}{epOmbre}[0.125]{\def\bcval@epOmbre{#1}}%
166 \define@key{bclogo}{arrondi}[0]{\def\bcval@arrondi{#1}}%
167 \define@key{bclogo}{couleurOmbre}[black]{\def\bcval@couleurOmbre{#1}}%
168 \define@key{bclogo}{couleurBarre}[black]{\def\bcval@couleurBarre{#1}}%
169 \define@key{bclogo}{couleurBord}[black]{\def\bcval@couleurBord{#1}}% modification Philippe Fortemps
170 \define@key{bclogo}{couleurTexte}[black]{\def\bcval@couleurTexte{#1}}%
171 \define@key{bclogo}{imageBarre}[]{\def\bcval@imageBarre{#1}}%
172 \define@key{bclogo}{motifBarre}[*]{\def\bcval@motifBarre{#1}}%
173 \define@key{bclogo}{marge}[4]{\setlength{\bcval@framesep}{#1 pt}}%
174 \define@key{bclogo}{margeG}[0]{\setlength{\bcval@margeG}{#1 cm}}%
175 \define@key{bclogo}{margeD}[0]{\setlength{\bcval@margeD}{#1 cm}}%
176 \define@key{bclogo}{sousTitre}[]{\def\bcval@sousTitre{#1}}%
177 \define@key{bclogo}{epBarre}[1.5]{\setlength{\bcval@epBarre}{#1 pt}}%
178 \define@key{bclogo}{epBord}[0.8]{\setlength{\bcval@borderWidth}{#1 pt}%
179         \ifdimgreater{\bcval@borderWidth}{\z@}{\KV@bclogo@noborderfalse}{\KV@bclogo@nobordertrue}%
180         }%
181 \define@key{bclogo}{tailleOndu}[2.5]{\setlength{\bcval@tailleOndu}{#1 pt}}%
182 \define@boolkey{bclogo}{cadreTitre}[true]{}%
183 \define@boolkey{bclogo}{noborder}[true]{\ifKV@bclogo@noborder\setlength{\bcval@borderWidth}{\z@}\fi}%
184 \define@boolkey{bclogo}{ombre}[true]{}%
185 \define@boolkey{bclogo}{avecBarre}[true]{}%
186 \define@boolkey{bclogo}{nobreak}[true]{}%
187 \define@boolkey{bclogo}{blur}[true]{\ifKV@bclogo@blur\KV@bclogo@ombretrue\fi}%
188 \define@choicekey{bclogo}{barre}{none,line,snake,motif,zigzag,imageExt,imageClip, wave}[line]{%
189 \ifthenelse{\equal{#1}{none}}{\KV@bclogo@avecBarrefalse\gdef\bc@barre{}}%
190 {\gdef\bc@barre{\ifKV@bclogo@avecBarre\@nameuse{bc@barre#1}\fi}}%
191 }%
192 %
193 % selection par defaut
194 \presetkeys{bclogo}{logo,barre,couleur,arrondi,couleurOmbre,couleurTexte,couleurBarre,epOmbre,epBarre,epBord,tailleOndu,ombre=false,cadreTitre=false,%
195 avecBarre=true,noborder=false,marge,sousTitre, couleurBord,blur=false,nobreak=false}{}%
196 %
197 %les differentes commandes de barre verticale a gauche
198 %
199 \newcommand{\bc@barreline}{%
200 \begin{minipage}{\logowidth}\centering%
201 \ifbclogotikz%
202 \begin{tikzpicture}%
203 \draw[line width=\bcval@epBarre,line cap=butt,color=\bcval@couleurBarre](0,\bc@invboxh)--(0,0);\end{tikzpicture}%
204 \else%
205 \psset{unit=1pt}%
206 \begin{pspicture}(0,0)(0,\bc@invboxh)%
207 \psline[linewidth=\bcval@epBarre,linecolor=\bcval@couleurBarre](0,\bc@invboxh)(0,0)%
208 \end{pspicture}%
209 \fi%
210 \end{minipage}}%
211 %
212 \newcommand{\bc@barremotif}{%
213 \begin{minipage}{\logowidth}\color{\bcval@couleurBarre}\centering%
214 \vbox to \bc@invboxh{\cleaders\vbox{\vss \bcval@motifBarre \vss}\vfill}%
215 \end{minipage}}%
216 %
217 \newcommand{\bc@barrewave}{%
218 \begin{minipage}{\logowidth}\color{\bcval@couleurBarre}\centering%
219 \vbox to \bc@invboxh{\cleaders\vbox{\vss $\leftwave\right.$ \vss}\vfill}%
220 \end{minipage}}%
221 %
222 \newcommand{\bc@barresnake}{%
223 \begin{minipage}{\logowidth}\centering%
224 \ifbclogotikz%
225 \begin{tikzpicture}[decoration={snake,segment length=2.66\bcval@tailleOndu, amplitude=\bcval@tailleOndu}]%
226 \draw[decorate,line width=1pt, color=\bcval@couleurBarre](0,\bc@invboxh)--(0,0);\end{tikzpicture}%
227 \else%
228 \psset{unit=1pt}%
229 \begin{pspicture}(0,0)(0,\bc@invboxh)%
230 \pszigzag[coilarm=0pt,coilwidth=2\bcval@tailleOndu,linewidth=1pt,linearc=1pt,coilheight=1.33,linecolor=\bcval@couleurBarre](0,\bc@invboxh)(0,0)%
231 \end{pspicture}%
232 \fi%
233 \end{minipage}}%
234 %
235 \newcommand{\bc@barrezigzag}{%
236 \begin{minipage}{\logowidth}\centering%
237 \ifbclogotikz%
238 \begin{tikzpicture}[decoration={zigzag,segment length=2.66\bcval@tailleOndu, amplitude=\bcval@tailleOndu}]%
239 \draw[decorate,line width=1pt,color=\bcval@couleurBarre](0,\bc@invboxh)--(0,0);\end{tikzpicture}%
240 \else%
241 \psset{unit=1pt}%
242 \begin{pspicture}(0,0)(0,\bc@invboxh)%
243 \pszigzag[coilarm=0pt,coilwidth=2\bcval@tailleOndu,linewidth=1pt,linearc=0pt,coilheight=1.33,linecolor=\bcval@couleurBarre](0,\bc@invboxh)(0,0)%
244 \end{pspicture}%
245 \fi%
246 \end{minipage}}%
247 %
248 \newcommand{\bc@barreimageExt}{% l'image est deformee
249 \begin{minipage}{\logowidth}\centering%
250 \includegraphics[width=\logowidth,height=\bc@invboxh]{\bcval@imageBarre}%
251 \end{minipage}}%
252 %
253 \newcommand{\bc@barreimageClip}{%
254 \begin{minipage}{\logowidth}\centering%
255 \includegraphics[viewport=0 0 \logowidth~ \bc@invboxh,%
256 clip=true]{\bcval@imageBarre}%
257 \end{minipage}}%
258 %
259 %======================= Quelques definitions===================================
260 % boite titre
261 \newsavebox{\bc@envbox}%
262 %%% precaution JCC
263 \newcommand*\bclogotitre{}%
264 \newcommand\bcStyleSousTitre[1]{\normalsize \textit{#1}}%
265 \newcommand\styleSousTitre[1]{\bcStyleSousTitre{#1}}% pour la compatibilit
266 \newcommand\bcStyleTitre[1]{\large \textbf{#1}}%
267 %======================= L'environnement =======================================
268 %
269 \newenvironment*{bclogo}[2][]{%
270    \setkeys{bclogo}{#1}%options
271    \renewcommand*\bclogotitre{#2}%
272   % deux types de titres
273    \ifKV@bclogo@cadreTitre% si cadreTitre = true
274        \def\bc@structitre{%
275             \hfil%
276             \ifbclogotikz% cadreTitre tikz
277             \begin{tikzpicture}%
278                 \node[rectangle, thick, top color=red!60!green!40, bottom color=white,draw]{\large #2};%
279             \end{tikzpicture}%
280             \else% cadreTitre pstricks
281             \psframebox[fillstyle=gradient,gradmidpoint=0.2, gradangle=0,gradbegin=red!60!green!40, gradend=white]{\large  #2}%
282             \fi%
283             \hfil%
284         }%
285   \else%sinon cadreTitre = false
286       \def\bc@structitre{\bcStyleTitre{#2} \bcStyleSousTitre{\bcval@sousTitre}}%
287   \fi%
288 %boite logo+titre
289 \setlength{\bc@titleLength}{%
290 \dimexpr\linewidth-\bcval@margeD-\bcval@margeG-1.5\bcval@framesep-\ifKV@bclogo@noborder\z@\else2\bcval@borderWidth\fi-%
291 \logowidth-\ifKV@bclogo@ombre\bcval@epOmbre cm\else\z@\fi\relax}%
292 %
293    \begin{lrbox}{\bc@envbox}% boite titre
294      \begin{tabular}{@{}c@{}p{\bc@titleLength}@{}}%
295        \begin{minipage}{\logowidth}%
296                 \refstepcounter{bclogocompteur}\bccaption{\bclogotitre}\bcval@logo%
297        \end{minipage}%
298      &%
299        \ifKV@bclogo@cadreTitre%
300          \begin{minipage}{\bc@titleLength}%
301                 \bc@structitre%
302          \end{minipage}%
303        \else\bc@structitre\fi%
304    \end{tabular}%
305   \end{lrbox}%
306 % affichage
307 %\smallskip% ressort %% Pourquoi ?
308 \def\bcval@nobreak{\ifKV@bclogo@nobreak true\else false\fi}% gestion nobreak
309 \mdframed[%
310  innerleftmargin={\dimexpr\ifKV@bclogo@avecBarre\logowidth\else\z@\fi+\bcval@framesep\relax},%
311  innertopmargin={\dimexpr\ht\bc@envbox+\dp\bc@envbox+\bcval@framesep\relax},%hauteur titre+framesep
312  innerrightmargin=\bcval@framesep,%
313  innerbottommargin=\bcval@framesep,%
314  rightmargin=\dimexpr\bcval@margeD+\ifKV@bclogo@ombre\bcval@epOmbre cm\else\z@\fi,%
315  leftmargin=\bcval@margeG,%
316  backgroundcolor=\bcval@couleur,%
317  fontcolor=\bcval@couleurTexte,%
318  linewidth=\bcval@borderWidth,%
319  roundcorner={\bcval@arrondi cm},%
320  \ifdef{\mdf@nobreak}{,nobreak=\bcval@nobreak}{}%%l'option nobreak de mdframed vient avec la version 0.9
321 ]%
322 }%
323 {%
324 \endmdframed\par%
325 \ifKV@bclogo@ombre\vspace*{\bcval@epOmbre cm}\else\smallskip\fi%
326 \goodbreak%
327 }%
328 \setkeys{bclogo}{barre=none}%% en cas d'utlisation de l'environnement mdframed 

Licence Creative Commons Les fichiers de Syracuse sont mis à disposition (sauf mention contraire) selon les termes de la
Licence Creative Commons Attribution - Pas d’Utilisation Commerciale - Partage dans les Mêmes Conditions 4.0 International.