acdcf5aceccb2ce06851caee2578ffe42f7be07e
[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
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
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 \newcommand{\bc@barremotif}{%
215 \begin{minipage}{\logowidth}\color{\bcval@couleurBarre}\centering%
216 \vbox to \bc@invboxh{\cleaders\vbox{\vss \bcval@motifBarre \vss}\vfill}%
217 \end{minipage}}%
218 %
219 \newcommand{\bc@barrewave}{%
220 \begin{minipage}{\logowidth}\color{\bcval@couleurBarre}\centering%
221 \vbox to \bc@invboxh{\cleaders\vbox{\vss $\leftwave\right.$ \vss}\vfill}%
222 \end{minipage}}%
223 %
224 \newcommand{\bc@barresnake}{%
225 \begin{minipage}{\logowidth}\centering%
226 \ifbclogotikz%
227 \begin{tikzpicture}[decoration={snake,segment length=2.66\bcval@tailleOndu, amplitude=\bcval@tailleOndu}]%
228 \draw[decorate,line width=1pt, color=\bcval@couleurBarre](0,\bc@invboxh)--(0,0);\end{tikzpicture}%
229 \else%
230 \psset{unit=1pt}%
231 \begin{pspicture}(0,0)(0,\bc@invboxh)%
232 \pszigzag[coilarm=0pt,coilwidth=2\bcval@tailleOndu,linewidth=1pt,linearc=1pt,coilheight=1.33,linecolor=\bcval@couleurBarre](0,\bc@invboxh)(0,0)%
233 \end{pspicture}%
234 \fi%
235 \end{minipage}}%
236 %
237 \newcommand{\bc@barrezigzag}{%
238 \begin{minipage}{\logowidth}\centering%
239 \ifbclogotikz%
240 \begin{tikzpicture}[decoration={zigzag,segment length=2.66\bcval@tailleOndu, amplitude=\bcval@tailleOndu}]%
241 \draw[decorate,line width=1pt,color=\bcval@couleurBarre](0,\bc@invboxh)--(0,0);\end{tikzpicture}%
242 \else%
243 \psset{unit=1pt}%
244 \begin{pspicture}(0,0)(0,\bc@invboxh)%
245 \pszigzag[coilarm=0pt,coilwidth=2\bcval@tailleOndu,linewidth=1pt,linearc=0pt,coilheight=1.33,linecolor=\bcval@couleurBarre](0,\bc@invboxh)(0,0)%
246 \end{pspicture}%
247 \fi%
248 \end{minipage}}%
249 %
250 \newcommand{\bc@barreimageExt}{% l'image est deformee
251 \begin{minipage}{\logowidth}\centering%
252 \includegraphics[width=\logowidth,height=\bc@invboxh]{\bcval@imageBarre}%
253 \end{minipage}}%
254 %
255 \newcommand{\bc@barreimageClip}{%
256 \begin{minipage}{\logowidth}\centering%
257 \includegraphics[viewport=0 0 \logowidth~ \bc@invboxh,%
258 clip=true]{\bcval@imageBarre}%
259 \end{minipage}}%
260 %
261 %======================= Quelques definitions===================================
262 % boite titre
263 \newsavebox{\bc@envbox}%
264 %%% precaution JCC
265 \newcommand*\bclogotitre{}%
266 \newcommand\bcStyleSousTitre[1]{\normalsize \textit{#1}}%
267 \newcommand\styleSousTitre[1]{\bcStyleSousTitre{#1}}% pour la compatibilit
268 \newcommand\bcStyleTitre[1]{\large \textbf{#1}}%
269 %======================= L'environnement =======================================
270 %
271 \newenvironment*{bclogo}[2][]{%
272    \setkeys{bclogo}{#1}%options
273    \renewcommand*\bclogotitre{#2}%
274   % deux types de titres
275    \ifKV@bclogo@cadreTitre% si cadreTitre = true
276        \def\bc@structitre{%
277             \hfil%
278             \ifbclogotikz% cadreTitre tikz
279             \begin{tikzpicture}%
280                 \node[rectangle, thick, top color=red!60!green!40, bottom color=white,draw]{\large #2};%
281             \end{tikzpicture}%
282             \else% cadreTitre pstricks
283             \psframebox[fillstyle=gradient,gradmidpoint=0.2, gradangle=0,gradbegin=red!60!green!40, gradend=white]{\large  #2}%
284             \fi%
285             \hfil%
286         }%
287   \else%sinon cadreTitre = false
288       \def\bc@structitre{\bcStyleTitre{#2} \bcStyleSousTitre{\bcval@sousTitre}}%
289   \fi%
290 %boite logo+titre
291 \setlength{\bc@titleLength}{%
292 \dimexpr\linewidth-\bcval@margeD-\bcval@margeG-1.5\bcval@framesep-\ifKV@bclogo@noborder\z@\else2\bcval@borderWidth\fi-%
293 \logowidth-\ifKV@bclogo@ombre\bcval@epOmbre cm\else\z@\fi\relax}%
294 %
295    \begin{lrbox}{\bc@envbox}% boite titre
296      \begin{tabular}{@{}c@{}p{\bc@titleLength}@{}}%
297        \begin{minipage}{\logowidth}%
298                 \refstepcounter{bclogocompteur}\bccaption{\bclogotitre}\bcval@logo%
299        \end{minipage}%
300      &%
301        \ifKV@bclogo@cadreTitre%
302          \begin{minipage}{\bc@titleLength}%
303                 \bc@structitre%
304          \end{minipage}%
305        \else\bc@structitre\fi%
306    \end{tabular}%
307   \end{lrbox}%
308 % affichage
309 \smallskip% ressort %% Pourquoi ? %%%parce que ça se comprime et ça s'étire!
310 \def\bcval@nobreak{\ifKV@bclogo@nobreak true\else false\fi}% gestion nobreak
311 \begin{mdframed}[%
312  innerleftmargin={\dimexpr\ifKV@bclogo@avecBarre\logowidth\else\z@\fi+\bcval@framesep\relax},%
313  innertopmargin={\dimexpr\ht\bc@envbox+\dp\bc@envbox+\bcval@framesep\relax},%hauteur titre+framesep
314  innerrightmargin=\bcval@framesep,%
315  innerbottommargin=\bcval@framesep,%
316  rightmargin=\dimexpr\bcval@margeD+\ifKV@bclogo@ombre\bcval@epOmbre cm\else\z@\fi,%
317  leftmargin=\bcval@margeG,%
318  backgroundcolor=\bcval@couleur,%
319  fontcolor=\bcval@couleurTexte,%
320  linewidth=\bcval@borderWidth,%
321  roundcorner={\bcval@arrondi cm},%
322  nobreak=\bcval@nobreak%%l'option nobreak de mdframed vient avec la version 0.9
323 ]%
324 }%
325 {%
326 \end{mdframed}\par%
327 \ifKV@bclogo@ombre\vspace*{\bcval@epOmbre cm}\else\smallskip\fi%
328 \goodbreak%
329 }%
330 \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.