summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/misc209/hangcaption.sty
blob: 6a7e3fb5b62572e7d6042aed6e49fb521e2d5ff5 (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
%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     filename        = "hangcaption.sty",
%%%     version         = "2.00",
%%%     date            = "27 August 1992",
%%%     time            = "22:23:46 EDT",
%%%     author          = "David M. Jones",
%%%     address         = "MIT Laboratory for Computer Science
%%%                        Room NE43-316
%%%                        545 Technology Square
%%%                        Cambridge, MA 02139
%%%                        USA",
%%%     telephone       = "(617) 253-5936",
%%%     FAX             = "(617) 253-3480",
%%%     checksum        = "57880 113 520 5319",
%%%     email           = "dmjones@theory.lcs.mit.edu",
%%%     codetable       = "ISO/ASCII",
%%%     keywords        = "LaTeX, caption",
%%%     supported       = "no",
%%%     abstract        = "Defines a variant of the caption command to
%%%                        produce captions with hanging
%%%                        indentation.",
%%%     docstring       = "This is the debugged version of a modified
%%%                        caption macro, \hangcaption, to produce
%%%                        captions with hanging indentation, like
%%%                        this:
%%%
%%%                        Figure 1.1: XXXXX XXX XXXX XXXX XXX
%%%                                    XXX XXX XXX XXX XX XXX
%%%
%%%                        The length variable \captionwidth controls
%%%                        how the caption is typeset.  If the width
%%%                        of the caption is less than \captionwidth,
%%%                        the \hangcaption is typeset the same way a
%%%                        short \caption would be (usually centered).
%%%                        Otherwise, it is set as shown above, with a
%%%                        total width equal to \captionwidth.
%%%                        \captionwidth is set to \hsize normally,
%%%                        but you may want to change it temporarily
%%%                        to match the width of a \tabular*
%%%                        environment, for example.
%%%
%%%                        \hangcaption is used in the same way as
%%%                        \caption.  To retain compatibility with
%%%                        previous versions of this style, the
%%%                        \hangcaption is also available under the
%%%                        name \isucaption.
%%%
%%%                        I did not write this file.  The original
%%%                        author is unknown.  However, I did fix a bug,
%%%                        namely, I removed a superflous "^^" that was
%%%                        causing one of the close braces to be
%%%                        interpreted as an equals sign, thus messing
%%%                        up the brace balancing.  I also tacked an
%%%                        "\endinput" on to the end of the file and
%%%                        added this header, and incorporated a few
%%%                        changes suggested by Harm Bakker, George
%%%                        Greenwade, and Rainer Schoepf.
%%%
%%%                        v2.00 (27 Aug 1992): altered \numberline to
%%%                        use \the... instead of \fnum@... (fix due to
%%%                        Harm Bakker <bakker@cs.rulimburg.nl>).
%%%                        Changed \isucaption to \hangcaption at George
%%%                        Greenwade's <bed_gdg@SHSU.edu> suggestion.
%%%
%%%                        v1.03 (12 August 1992): minor changes to
%%%                        header.
%%%
%%%                        v1.02 (12 August 1992): patches by Rainer
%%%                        Schoepf <schoepf@sc.ZIB-Berlin.DE> to (a)
%%%                        work around a bug in LaTeX and (b) measure
%%%                        the caption correctly by including room for
%%%                        the colon and the space.
%%%
%%%                        The checksum field above contains a CRC-16
%%%                        checksum as the first value, followed by the
%%%                        equivalent of the standard UNIX wc (word
%%%                        count) utility output of lines, words, and
%%%                        characters.  This is produced by Robert
%%%                        Solovay's checksum utility.",
%%%  }
%%% ====================================================================

\newlength\captionwidth \captionwidth=\hsize

\def\hangcaption{\refstepcounter\@captype\@dblarg{\@hangcaption\@captype}}

\long\def\@hangcaption#1[#2]#3{%
  \baselineskip 14.5\p@
  \addcontentsline{\csname ext@#1\endcsname}{#1}%
    {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
  \par
  \begingroup
    \@parboxrestore
    \setbox\@tempboxa\hbox{\csname fnum@#1\endcsname: #3}%
    \ifdim \wd\@tempboxa > \captionwidth
      \begingroup
        \setbox\@tempboxa\hbox{\csname fnum@#1\endcsname: }%
        \advance \captionwidth by -\wd\@tempboxa
        \@makecaption{\csname fnum@#1\endcsname}%
            {\ignorespaces{\protect\parbox[t]{\captionwidth}{\leavevmode#3}}}%
      \endgroup
    \else
      \begingroup
        \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}%
      \endgroup
    \fi
    \par\vspace{1.7ex}%
  \endgroup}

\let\isucaption\hangcaption

\endinput