bjr@clarity.Princeton.EDU (Brian J. Reiser) (08/31/90)
Is there any simple way to modify the formatting of latex figure captions? I have some longish captions (approx 3-4 sentences) that are associated with some graphs included in the document as figures. The default formatting for \caption is apparently the normal text size, and if the text is longer than one line, it is in a paragraph the same width as the text. I would like to have the captions printed slightly smaller, and in a width indented from the width of the text. At the suggestion of a colleague, I tried defining my own version of \caption: \newcommand{\figcaption}[1]{\begin{center} \parbox[t]{5in}{\caption{\protect\small #1}} \end{center}} But this is not ideal because (1) only the text of the caption is made the smaller size, but the words "Figure 11" are the regular text size, and (2) extra vertical space is skipped above the parbox, so that the caption is further from the picture in the figure than it would otherwise be. Does anyone have a better suggestion? Are there some size and indentation parameters I could simply adjust that are used by \caption, or is there a better way to define my own caption? Thanks, Brian J. Reiser Princeton University Cognitive Science Laboratory Internet: reiser@princeton.edu
jdm5548@diamond.tamu.edu (James Darrell McCauley) (08/31/90)
In article <BJR.90Aug30155525@clarity.Princeton.EDU>, bjr@clarity.Princeton.EDU (Brian J. Reiser) writes: |> Is there any simple way to modify the formatting of latex figure |> captions? I have some longish captions (approx 3-4 sentences) that |> are associated with some graphs included in the document as figures. |> The default formatting for \caption is apparently the normal text |> size, and if the text is longer than one line, it is in a paragraph |> the same width as the text. I would like to have the captions printed |> slightly smaller, and in a width indented from the width of the text. |> |> At the suggestion of a colleague, I tried defining my own version of \caption: |> |> \newcommand{\figcaption}[1]{\begin{center} |> \parbox[t]{5in}{\caption{\protect\small #1}} |> \end{center}} ... |> Does anyone have a better suggestion? Is this better? The words "Figure 11" are the same size as the text: \newcommand{\figcaption}[1]{\begin{center} \addtocounter{figure}{1} \parbox[t]{5in}{\protect\small Figure \thefigure : #1} \end{center}} --- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - James Darrell McCauley jdm5548@diamond.tamu.edu Dept of Ag. Engineering (409) 845-6484 Texas A&M University, College Station, Texas 77843-2117, USA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dhosek@sif.claremont.edu (Hosek, Donald A.) (08/31/90)
In article <7865@helios.TAMU.EDU>, jdm5548@diamond.tamu.edu (James Darrell McCauley) writes... ->In article <BJR.90Aug30155525@clarity.Princeton.EDU>, ->bjr@clarity.Princeton.EDU (Brian J. Reiser) writes: ->|> Is there any simple way to modify the formatting of latex figure ->|> captions? I have some longish captions (approx 3-4 sentences) that ->|> are associated with some graphs included in the document as figures. ->|> The default formatting for \caption is apparently the normal text ->|> size, and if the text is longer than one line, it is in a paragraph ->|> the same width as the text. I would like to have the captions printed ->|> slightly smaller, and in a width indented from the width of the text. ->|> At the suggestion of a colleague, I tried defining my own version of ->\caption: ->|> \newcommand{\figcaption}[1]{\begin{center} ->|> \parbox[t]{5in}{\caption{\protect\small #1}} ->|> \end{center}} ->.... ->|> Does anyone have a better suggestion? ->Is this better? The words "Figure 11" are the same size as the text: ->\newcommand{\figcaption}[1]{\begin{center} -> \addtocounter{figure}{1} -> \parbox[t]{5in}{\protect\small -> Figure \thefigure : #1} -> \end{center}} Sigh. Suppose he wanted a list of figures too? OK, the correct way for changing the formatting of a caption: LaTeX defines \caption so that the actual printing of the caption text is handled by the \@makecaption macro. For example, article.sty defines \@makecaption to center the caption if it is one line or less and to typeset it as a paragraph otherwise with the definition: % \@makecaption{NUMBER}{TEXT} : Macro to make a figure or table caption. % NUMBER : Figure or table number--e.g., 'Figure 3.2' % TEXT : The caption text. % Macro should be called inside a \parbox of right width, with \normalsize. % changed 25 Jun 86 to fix according to Howard Trickey: % instead of \unhbox\@tempboxa\par we do #1: #2\par \long\def\@makecaption#1#2{ \vskip 10pt \setbox\@tempboxa\hbox{#1: #2} \ifdim \wd\@tempboxa >\hsize % IF longer than one line: #1: #2\par % THEN set as ordinary paragraph. \else % ELSE center. \hbox to\hsize{\hfil\box\@tempboxa\hfil} \fi} The following code (placed in mycaption.sty, say) will produce centered nine-point captions in 10pt text (the caption size will increase with the text size as \small grows). \long\def\@makecaption#1#2{ \begin{center} \small #1: #2\par \end{center}} Note that the \vskip was removed since the center environment carries its own space around with it. -dh --- Don Hosek TeX, LaTeX, and Metafont support, consulting dhosek@ymir.claremont.edu installation and production work. dhosek@ymir.bitnet Free Estimates. uunet!jarthur!ymir Phone: 714-625-0147 finger dhosek@ymir.claremont.edu for more info
spang@nbivax.nbi.dk (Karsten Spang) (08/31/90)
In article <BJR.90Aug30155525@clarity.Princeton.EDU>, bjr@clarity.Princeton.EDU (Brian J. Reiser) writes: > Is there any simple way to modify the formatting of latex figure > captions? >... > I would like to have the captions printed > slightly smaller, and in a width indented from the width of the text. This is how I use to do it, it is a simple minded approach that does not change any existing definitions, you have to do some extra typing, but on the other hand, using an editor, you just copy your last figure. After \begin{document} I insert the lines \newlength{\capwidth} \setlength{\capwidth}{\textwidth} \addtolength{\capwidth}{-2cm} and each figure I make like \begin{figure}[htbp] \begin{center} \begin{picture}(x,y) \put(a,b){...} ... \end{picture} \parbox{\capwidth}{ \caption[Short caption for LOF] {This is the long caption that I need to break over several lines, because it does not fit on one line. Consequently, it would exceed TeX capacity, and it would look awful, if included in the list of tables} \label{fig:something} } \end{center} \end{figure} This scheme indents the caption 1cm from the left and right, but it does not change the point size of the caption. Karsten -------------------------------------------------------------------------------- InterNet: spang@nbivax.nbi.dk (nbivax=129.142.100.3) Karsten Spang NORDUNET/HEPnet:NBIVAX::SPANG (NBIVAX=21.601=22105) Niels Bohr Institutet VAXPSI MAIL: (0)238301032352::SPANG Blegdamsvej 17 Phone: +45 31 42 16 16 ext. 255 Fax: +45 31 42 10 16 DK-2100 Copenhagen X Direct: +45 31 42 42 84-255 Telex: 15216 nbi dk Denmark
djs@media-lab.MEDIA.MIT.EDU (David J. Sturman) (09/01/90)
In article <BJR.90Aug30155525@clarity.Princeton.EDU> bjr@clarity.Princeton.EDU (Brian J. Reiser) writes: >Is there any simple way to modify the formatting of latex figure >captions? I have some longish captions (approx 3-4 sentences) that I had the same problem and solved it by defining my own caption macro for LaTeX, shown below. It provides a multi-line caption centered and .25 inches shorter than the currently operating paragraph width, in a slightly smaller font. The macros take two arguments, the caption title that gets put into a table of contents, and the paragraph of text that should follow. Note that the first argument, the 'caption title', is not printed with the figure so that you have to repeat the title in the second argument. The macro is: \newcommand{\mycaption}[2]{ \begin{center} \advance\textwidth by -0.5in \parbox{\the\textwidth}{ \caption[#1]{\small #2 \normalsize} } % end of parbox \end{center} } % end of newcommand You use it in the following way. The caption is "My caption title" and I have it printing out in italics (\em). \begin{figure} \label{a-nice-figure} \psfig{figure=a-nice-figure.ps} \mycaption {My caption title} {{\em My caption title}\ \ This is a long paragraph that is to be put as comment to the caption of a figure in a document. It can go on and on... ... ... and ends here } \end{figure} Good luck. David Sturman MIT Media Lab djs@media-lab.media.mit.edu
bjr@clarity.Princeton.EDU (Brian J. Reiser) (09/03/90)
In article <8240@jarthur.Claremont.EDU> dhosek@sif.claremont.edu (Hosek, Donald A.) writes: In article <7865@helios.TAMU.EDU>, jdm5548@diamond.tamu.edu (James Darrell McCauley) writes... ->In article <BJR.90Aug30155525@clarity.Princeton.EDU>, ->bjr@clarity.Princeton.EDU (Brian J. Reiser) writes: ->|> Is there any simple way to modify the formatting of latex figure ->|> captions? I have some longish captions (approx 3-4 sentences) that ->|> are associated with some graphs included in the document as figures. ->|> The default formatting for \caption is apparently the normal text ->|> size, and if the text is longer than one line, it is in a paragraph ->|> the same width as the text. I would like to have the captions printed ->|> slightly smaller, and in a width indented from the width of the text. OK, the correct way for changing the formatting of a caption: LaTeX defines \caption so that the actual printing of the caption text is handled by the \@makecaption macro. For example, article.sty defines \@makecaption to center the caption if it is one line or less and to typeset it as a paragraph otherwise with the definition: [original \@makecaption macro and hosek's revision deleted] Thanks to everybody for their suggestions on how to solve this problem. The solution I pulled together from everybody's suggestions is: \long\def\@makecaption#1#2{ \vskip 10pt \setbox\@tempboxa\hbox{\small #1: #2} \ifdim \wd\@tempboxa >0.8\hsize % IF longer than one line: \quote {\small #1: #2\par}\endquote % THEN set as quote paragraph \else % ELSE center. \hbox to\hsize{\hfil\box\@tempboxa\hfil} \fi} -- Brian Reiser Cognitive Science Laboratory Princeton University