Retour

illustr.tex

Télécharger le fichier
%% fichier 'illustr.tex'
%% essais pour la creation d'une macro \illustrate
%% version 1 (22/12/96)
 
\catcode`\@ = 11
 
\newbox \illustrateb@x
 
\def \bmppath{}
 
% ============== commandes de base =======================
% affichage d'une \hbox de la taille desiree, cette hbox
% contenant un ordre \special pour charger un fichier .bmp
% ATTENTION : on utilise la macro \bmppath, initialisee au
% vide pour commencer
 
% la routine commnue aux suivantes
\def \bmpillustr@te#1#2#3{%   #1 = file, #2 = width, #3 = height
   \setbox \illustrateb@x = \hbox{%
   \special{bmp: \bmppath/#1 
      x=#2 
      y=#3}}
   \dp \illustrateb@x = 0cm
   \ht \illustrateb@x = #3
   \wd \illustrateb@x = #2 }
 
% la commande de base
\def \bmpillustrate#1#2#3{%   #1 = file, #2 = width, #3 = height
   \bmpillustr@te{#1}{#2}{#3}
   \box \illustrateb@x }
 
% ici, on a en plus un \boxit
\def \boxbmpillustrate#1#2#3{%  #1 = file, #2 = width, #3 = height
   \bmpillustr@te{#1}{#2}{#3}
   \boxit{0.5pt}{\box \illustrateb@x }}
 
% ici, on a en plus un \superboxit
\def \superboxbmpillustrate#1#2#3{%  #1 = file, #2 = width, #3 = height
   \bmpillustr@te{#1}{#2}{#3}
   \superboxit{0.5pt}{\box \illustrateb@x }}
 
\newbox \illustrateb@x
\newdimen \xsizeillustrateb@x
\newdimen \ysizeillustrateb@x
 
\def \epspath{}
 
\newbox \legendb@x
\def \legende#1{%
   \setbox \legendb@x = \hbox{#1\tvi }}
 
% la routine commune aux suivantes
\def \epsillustr@te#1{%   #1 = file
   \setbox \illustrateb@x = \hbox{\epsfbox{#1}}
   \xsizeillustrateb@x = \wd \illustrateb@x
   \ysizeillustrateb@x = \ht \illustrateb@x
}
 
% la commande de base
\def \epsillustrate#1{%   #1 = file
   \epsillustr@te{\epspath #1}
   \box \illustrateb@x}
 
% ici, on a en plus un \boxit
\def \boxepsillustrate#1{%  #1 = file
   \epsillustr@te{\epspath #1}
   \boxit{0.5pt}{\box \illustrateb@x}}
 
% ici, on a en plus un \superboxit
\def \superboxepsillustrate#1{%  #1 = file
   \epsillustr@te{\epspath #1}
   \vbox{%
      \superboxit{0.5pt}{\box \illustrateb@x}
      \hbox to \xsizeillustrateb@x {%
         \hfil 
         \box \legendb@x 
         \hfil}
   }}
 
% ============== affichage en bordure du texte =========================
 
% la macro modifiée de l'exercice 14.24 du TeXbook 
\let \savepar \par
\def \hangcarryover{%
   \edef \next{%			%% sauvegarde les valeurs
      \hangafter \the \hangafter	%% courantes (qui sont remises
      \hangindent \the \hangindent}	%% à 0 à la fin du paragraphe)
   \savepar
   \next				%% restore \hangindent et \hangafter
   \edef \next{%
      \prevgraf \the \prevgraf}		%% sauvegarde le nb de lignes déjà composées
%%%%%%%%%%%%%%%% modif 26/11/96      \indent
   \noindent
   \next}				%% et les restore
 
% =============================== la figure a droite ===
 
% ma tentative de \rightillustrate~: la commande de base, qui
% permet d'afficher du 'vertical material' a droite du texte
 
\def \rightillustrate#1#2{%         % #1 = vertical material, #2 = nb lines
   \setbox\tmpbox \vbox{\unvbox#1}  % on stocke le materiel en box10,
   \ht\tmpbox = 0pt                 % dont on annule ht et dp
   \dp\tmpbox = 0pt
   \line{%                          % on affiche dans une ligne de
      \hfill                        % hauteur nulle
      {\copy \tmpbox }}
   \vskip-\baselineskip             % on rectif le saut interligne
   \hangindent = -1.1 \wd\tmpbox    % et on prepare le decalage de droite
   \hangafter = #2
   \def \par{%				%% on redéfinit le \par
      \ifnum \prevgraf > -\hangafter	%% qui reste actif tant que l'on
         \let \par \savepar		%% a pas composé suffisamment de lignes
         \par
      \else
         \hangcarryover
      \fi}}
 
% les commandes annexes
\def \rightbmpillustrate#1#2#3#4{%  #1 = file, #2 = width, #3 = height, #4 = nb lines
   \setbox \tmpbox \vbox{%
      \bmpillustrate{#1}{#2}{#3}}
   \rightillustrate{\tmpbox}{#4}}
 
\def \rightboxbmpillustrate#1#2#3#4{%  #1 = file, #2 = width, #3 = height, #4 = nb lines
   \setbox \tmpbox \vbox{%
      \boxbmpillustrate{#1}{#2}{#3}}
   \rightillustrate{\tmpbox}{#4}}
 
\def \rightsuperboxbmpillustrate#1#2#3#4{%  #1 = file, #2 = width, #3 = height, #4 = nb lines
   \setbox \tmpbox \vbox{%
      \superboxbmpillustrate{#1}{#2}{#3}}
   \rightillustrate{\tmpbox}{#4}}
 
% les commandes annexes
\def \rightepsillustrate#1#2{%  #1 = file, #2 nb lines
   \setbox \tmpbox \vbox{%
      \epsillustrate{#1}}
   \rightillustrate{\tmpbox}{#2}}
 
\def \rightboxepsillustrate#1#2{%  #1 = file, #2 = nb lines
   \setbox \tmpbox \vbox{%
      \boxepsillustrate{#1}}
   \rightillustrate{\tmpbox}{#2}}
 
\def \rightsuperboxepsillustrate#1#2{%  #1 = file, #2 = nb lines
   \setbox \tmpbox \vbox{%
      \superboxepsillustrate{#1}}
   \rightillustrate{\tmpbox}{#2}}
 
% === la figure a gauche ===============================
 
% ma tentative de \leftillustrate~: la commande de base, qui
% permet d'afficher du 'vertical material' a gauche du texte
 
\def \leftillustrate#1#2{%        % #1 = vertical material, #2 = nb lines
   \setbox10 \vbox{#1}            % on stocke le materiel en box10,
   \ht 10 = 0pt                   % dont on annule ht et dp
   \dp 10 = 0pt
   \line{%                        % on affiche dans une ligne de
      {\copy 10 }                 % hauteur nulle
      \hfill}
   \vskip-\baselineskip           % on rectif le saut interligne
   \hangindent = 1.1 \wd10        % et on prepare le decalage de droite
   \hangafter = #2
   \def \par{%				%% on redéfinit le \par
      \ifnum \prevgraf > -\hangafter	%% qui reste actif tant que l'on
         \let \par \savepar		%% a pas composé suffisamment de lignes
         \par
      \else
         \hangcarryover
      \fi}}
 
% les commandes annexes
\def \leftbmpillustrate#1#2#3#4{%  #1 = vertical material, #2 = width
   \leftillustrate{%            %  #3 = height, #4 = nb lines
      \vbox{\bmpillustrate{#1}{#2}{#3}}}%              
      {#4}} 
 
\def \leftboxbmpillustrate#1#2#3#4{%  #1 = vertical material, #2 = width
   \leftillustrate{%               %  #3 = height, #4 = nb lines
      \vbox{\boxbmpillustrate{#1}{#2}{#3}}}%              
      {#4}} 
 
\def \leftsuperboxbmpillustrate#1#2#3#4{%  #1 = vertical material, #2 = width
   \leftillustrate{%                    %  #3 = height, #4 = nb lines
      \vbox{\superboxbmpillustrate{#1}{#2}{#3}}}%              
      {#4}} 
 
% les commandes annexes
\def \leftepsillustrate#1#2{%   %  #1 = vertical material, #2 = nb lines
   \leftillustrate{%            
      \vbox{\epsillustrate{#1}}}%              
      {#2}}
 
\def \leftboxepsillustrate#1#2{%  #1 = vertical material, #2 = nb lines
   \leftillustrate{%               
      \vbox{\boxepsillustrate{#1}}}%              
      {#2}}
 
\def \leftsuperboxepsillustrate#1#2{%  #1 = vertical material, #2 = nb lines
   \leftillustrate{%               
      \vbox{\superboxepsillustrate{#1}}}%              
      {#2}}
 
\catcode`\@ = 12
 
%% test des macros \hangafter et \hangindent
%% Ici, on reprend juste le test3, et on essaye
%% de faire un peu plus propre