TransWikia.com

How can I change the name/caption of a latex table?

TeX - LaTeX Asked on December 16, 2020

My table names and captions are in the "classical" LaTeX format, such as "Table 1: Caption Text", but I wanted to make it like

 **Table 1**
Caption Text

Is there a way I can achieve this?

2 Answers

Assuming that by

**Table 1**

you mean bold-facing the label and its number, i.e., obtaining Table 1, using the caption package will let you achieve your formatting objective.

E.g.,

enter image description here

documentclass{article}
usepackage{caption}
captionsetup[table]{labelfont=bf,
                     labelsep=newline,
                     skip=0.333baselineskip}
begin{document}
begin{table} 
centering
caption{Caption Text} 
begin{tabular}{|cc|}
hline 
a & b  c & d 
hline
end{tabular}
end{table}
end{document}

Correct answer by Mico on December 16, 2020

Use the package caption and adapt the caption settings, marked as %<<<<

I just used a random table from another question to do the example. You might not need the other (useful) packages.

documentclass{article}
usepackage[table]{xcolor}
usepackage{booktabs,multirow}
usepackage{rotating}

RequirePackage{caption} %<<<<
DeclareCaptionLabelFormat{ast}{** Table #2 **} %<<<<
captionsetup{labelformat=ast,labelsep=newline, skip=0.5baselineskip} %<<<<

begin{document}

begin{table}[htbp]
    centering
    caption{My Caption 1}
    begin{tabular}{clr}
        toprule
        Alg.  & Dataset & Result 
        midrule
        multirow{4}[2]{*}{begin{sideways}BFSend{sideways}} & soc-ork  & 1.61 
        & cellcolor[rgb]{ .816,  .808,  .808}soc-lj & cellcolor[rgb]{ .816,  .808,  .808}2.95 
        & h09   & 1.60 
        & cellcolor[rgb]{ .816,  .808,  .808}i04 & cellcolor[rgb]{ .816,  .808,  .808}14.72 
        bottomrule
    end{tabular}%
    label{tab:addlabel}%
end{table}%

end{document}

The declare DeclareCaptionLabelFormat command example shows how to decorate the name of tables, figures, etc.

output

Answered by Simon Dispa on December 16, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP