Graphics, Figures & TablesFormatting tables, captions in preamble?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
fini_fly
Posts: 5
Joined: Tue Jan 20, 2009 8:58 pm

Formatting tables, captions in preamble?

Post by fini_fly »

I am writing a short report using the 'article' documentclass. I would like all of my tables to be a smaller font size than the rest of the text and I would like to have bold captions for figures and tables.

I would like to avoid having to format each cell to a specific font size. Also I can't seem to get bolded font for the captions.

Is there a way to do this in the preamble?
Last edited by fini_fly on Thu Jan 22, 2009 11:00 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Formatting tables, captions in preamble?

Post by localghost »

The caption package lets you customize captions of floats. This and other requested settings are demonstrated in the following example for a table.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[font=small,textfont=bf]{caption}
\usepackage{booktabs}
\usepackage{lmodern}
\usepackage{blindtext}

\parindent0em

\begin{document}
  \blindtext

  \begin{table}[!ht]
    \centering
    \small
    \caption{Dummy table}\label{tab:dummy}
    \begin{tabular}{cc} \toprule
      Measurement & Value \\ \midrule
      1 & 49587 \\
      2 & 39509 \\
      3 & 17389 \\ \bottomrule
    \end{tabular}
  \end{table}

  \blindtext
\end{document}
The used packages and their documentations can be found on CTAN or via command prompt on your local machine.

Code: Select all

texdoc babel

Best regards and welcome to the board
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
marco_d
Posts: 57
Joined: Tue Jan 20, 2009 7:49 pm

Formatting tables, captions in preamble?

Post by marco_d »

Hello,

a small addition:
To change the font size global you can define your own environment:

Code: Select all

\documentclass[english]{article}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\usepackage[bf]{caption}
\captionsetup[table]{position=above}
\newenvironment{mytable}[1][htb]
{\begin{table}[#1]\small\centering}%
{\end{table}
} 

\begin{document}
\blindtext
\begin{mytable}[ht]
\caption{position ht}
\begin{tabular}{cc}
 1 & 4 \\
\end{tabular}
\end{mytable}
\blindtext
\begin{mytable}
\caption{position p}
\begin{tabular}{cc}
 1 & 4 \\
\end{tabular}
\end{mytable}

\end{document}
Marco
i am German. I can not use difficult words. :-)
fini_fly
Posts: 5
Joined: Tue Jan 20, 2009 8:58 pm

Re: Formatting tables, captions in preamble?

Post by fini_fly »

Thanks for the quick response. I'll give both a shot and let you know how it all goes!

Thanks again.
fini_fly
Posts: 5
Joined: Tue Jan 20, 2009 8:58 pm

Formatting tables, captions in preamble?

Post by fini_fly »

I've tried both of your suggestions and they work to a point as I can only get the caption to be bolded. For example:

Figure 2: Figure 2 caption is bold

How about the 'Figure #' and 'Table #' parts?
marco_d
Posts: 57
Joined: Tue Jan 20, 2009 7:49 pm

Formatting tables, captions in preamble?

Post by marco_d »

Hello,

have you read the documentation of caption? Thorsten gave you the url. What do you mean with
Figure 2: Figure 2 caption is bold

How about the 'Figure #' and 'Table #' parts?
regards
Marco
i am German. I can not use difficult words. :-)
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Formatting tables, captions in preamble?

Post by localghost »

fini_fly wrote:I've tried both of your suggestions and they work to a point as I can only get the caption to be bolded. For example:

Figure 2: Figure 2 caption is bold

How about the 'Figure #' and 'Table #' parts?
A look at the manual of the package yields the solution. Simply change the options of package inclusion.

Code: Select all

\usepackage[font={small,bf}]{caption}
My first suggestion was based on the description in your initial post. For requests please describe the problem more precise.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
fini_fly
Posts: 5
Joined: Tue Jan 20, 2009 8:58 pm

Formatting tables, captions in preamble?

Post by fini_fly »

Sorry but I hadn't had a chance to check the documentation. This answered my question:

Code: Select all

\usepackage[font={footnotesize,bf}]{caption}
Post Reply