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

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.