In Brazil, we consider tables to be "charts" that follow specific formatting (the translation might be a little off here, but that's what I'll use for this question). This specific formatting includes column alignment and borders, for example.
Both tables and charts are easily created in the tabular
environment. My problem comes when I try to caption them separetely. The captions for the charts should say something like Chart 1: Example
, while the captions for the tables should be the default Table 1: Example
My idea was to "duplicate" the table
environment into something like the "mychart" environment, and then change this environment's captions. Is it the best way to achieve that or is there a better way to do it?
Note: I have tried using the captions
package \captionsetup{name=Chart}
command, it kinda worked, but the the tables and charts still shared the counters, so I had "chart 1 / table 2" instead of "chart 1 / table 1"…
Here I have a MWE of a table and a chart:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
This is a Table:
\begin{table}[h]
\centering
\caption{Example}
\begin{tabular}{l r}
\hline
City & Habitants \\
\hline
City A & 2000000 \\
City B & 4000000 \\
City C & 500000 \\
\hline
\end{tabular}
\end{table}
And this is a "chart": %might want to change the word
\begin{table}[h]
\centering
\caption{Example}
\begin{tabular}{|c c|}
\hline
City & Habitants \\
\hline
City A & 2000000 \\
\hline
City B & 4000000 \\
\hline
City C & 500000 \\
\hline
\end{tabular}
\end{table}
\end{document}
Best Answer
It would be advisable to create a separate float that contains your charts. That allows you to have a handle into changing things in the future. For example, if you decide to reformat them differently, or perhaps make them the same.
The
float
package can easily create new floats:A comparable setup using
newfloat
(compatible withcaption
) would be