summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/multicap/multicap.sty
blob: d05f71562f76b27ce9cc45ea05fb797ab51a22e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
%%
%%  multicap.sty
%%
%%  Copyright (C) 2002  John Vassilogiorgakis. 
%%                      Postgraduate student
%%                      Department of Informatics
%%                      University of Athens.  
%%
%%  Please report errors or suggestions for improvement to
%%                
%%                             giannis@iris.math.aegean.gr
%%
%%  This program may be distributed and/or modified under the
%%  conditions of the LaTeX Project Public License, either version 1.2
%%  of this license or (at your option) any later version.
%%  The latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%%  and version 1.2 or later is part of all distributions of LaTeX 
%%  version 1999/12/01 or later.
%%
%%  This program consists of the files multicap.dtx and multicap.sty
%%
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{multicap}[2002/05/04 
 v1.0 formatting captions inside multicols]%
\RequirePackage{ifthen}%
\newcommand*{\@mcaptype}{\@empty}%
\DeclareOption{Sans}%
 {\renewcommand*{\@mcaptype}{\textsf}}%
\DeclareOption{normal}%
 {\renewcommand*{\@mcaptype}{\relax}}%
\DeclareOption*%
 {\PackageWarning{multicap}{Unknown option 
 `\CurrentOption'.\MessageBreak
 Going into default mode}}%
\ExecuteOptions{Sans}%
\ProcessOptions*%
\newcounter{mcapsize}%
\newcounter{mcapskip}%
\newsavebox{\mf@tempbox}%                                       
\newsavebox{\mt@tempbox}%                                       
\newsavebox{\@temp@box}%
\newlength{\abvmcapskip}%
\newlength{\blwmcapskip}%
\setlength{\abvmcapskip}{10\p@}%
\setlength{\blwmcapskip}{\parsep}%
\newboolean{@cent@er}%
\renewenvironment*{center}%
 {\setboolean{@cent@er}{true}\trivlist%
 \centering\item\relax}%
 {\setboolean{@cent@er}{false}\endtrivlist}%
\DeclareRobustCommand*{\@mcap@size}{\relax}%
\newcommand*{\@mcap@fs}{%
 \ifthenelse{\equal{\value{mcapsize}}{0}%
  \and\equal{\value{mcapskip}}{0}}{}%
  {\renewcommand*{\@mcap@size}%
   {\fontsize{\value{mcapsize}}{\value{mcapskip}}%
    \selectfont%
   }%
  }%
}%
\newcommand*{\mfcaption}[2][\@empty]{%
 \\[\abvmcapskip]%
 \@mcap@fs%
 \refstepcounter{figure}%
 \ifthenelse{\equal{\protect#1}{\protect\@empty}}%
  {\addcontentsline{lof}{figure}%
   {\protect\numberline{\thefigure}#2}}%
  {\addcontentsline{lof}{figure}%
   {\protect\numberline{\thefigure}#1}}%
 \sbox{\mf@tempbox}{%
  \@mcap@size\@mcaptype{%
  \figurename\ \textsc{\thefigure{}:} #2%
  }%
 }%
 \ifthenelse{\lengthtest{\wd\mf@tempbox > \linewidth}}%
  {\begin{minipage}[t]{\linewidth}%
   \@mcap@size\@mcaptype%
   {\figurename\ \textsc{\thefigure{}:} #2}%
  \end{minipage}\par}%
  {{\centering\usebox{\mf@tempbox}\\}}%
 \ifthenelse{\boolean{@cent@er}}{}%
  {\vspace{\blwmcapskip}}%
}%
\newcommand*{\mtcaption}[2][\@empty]{%
 \\[\abvmcapskip]%
 \@mcap@fs%
 \refstepcounter{table}%
 \ifthenelse{\equal{\protect#1}{\protect\@empty}}%
  {\addcontentsline{lot}{table}%
   {\protect\numberline{\thetable}#2}}%
  {\addcontentsline{lot}{table}%
   {\protect\numberline{\thetable}#1}}%
 \sbox{\mt@tempbox}{%
  \@mcap@size\@mcaptype{%
   \tablename\ \textsc{\thetable{}:} #2%
  }%
 }%
 \ifthenelse{\lengthtest{\wd\mt@tempbox > \linewidth}}%
  {\begin{minipage}[t]{\linewidth}%
   \@mcap@size\@mcaptype%
   {\tablename\ \textsc{\thetable{}:} #2}%
  \end{minipage}\par}%
  {{\centering\usebox{\mt@tempbox}\\}}%
 \ifthenelse{\boolean{@cent@er}}{}%
  {\vspace{\blwmcapskip}}%
}%
\renewcommand{\@makecaption}[2]{%
 \vspace{10\p@}%
 \@mcap@fs%
 \sbox{\@temp@box}{\@mcap@size\@mcaptype{#1{}\textsc{:} #2}}%
 \ifthenelse{\lengthtest{\wd\@temp@box > \linewidth}}%
  {\@mcap@size\@mcaptype{#1{}\textsc{:} #2}\par}%
 {\centering\@mcap@size\@mcaptype{#1{}\textsc{:} #2}}%
}%
\endinput
%%
%% End of file `multicap.sty'.