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

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.