1

I have a problem with the caption of LaTeX tables. Is there any way to edit the caption of my LaTeX tables so that not all captions start with “Table1”

Can I edit the second file into displaying “Table 2” somehow? My tables are not all in a single file but each table is coded in a different file but I suppose that should not be the problem

\caption{bla}
\label{tab:xyz}
\end{table}
\end{document}

In case there is no simpel solution hwo could I integrate these tables

\documentclass[12pt]{article}
\usepackage{multirow}
\usepackage[landscape]{geometry}

\begin{document}
\begin{table}[ht]
\begin{center}
\begin{tabular}{ |l|l|l|l|l|}
\hline
% TABLE content
\hline
\end{tabular}
\end{center}
\caption{bla}
\end{table}
\end{document}

\documentclass[12pt]{article}
\usepackage{multirow}
\usepackage[landscape]{geometry}
\usepackage{booktabs}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\let\centering\relax
\begin{document}
\begin{table*}\centering
\ra{1.3}
% TABLE CONTENT
\bottomrule
\end{tabular}
\caption{bla2}
\end{table*}
\end{document}
Qrrbrbirlbel
  • 119,821
  • 2
    Welcome to TeX.sx! Can you be more precise about your workflow? – egreg Jan 28 '13 at 22:46
  • could you specify? I have several tables in different txt files ( I use MIKtex to compile them). While I can edit the 'bla'part the finished pdf always exhibits Table1:bla...... – Tim Heinert Jan 28 '13 at 22:49
  • that's helpul but is there also a way to not only suppress the 'Table 1' but also to replace it with Table 2 even if it is the first 'world table' if that's the right name for it – Tim Heinert Jan 28 '13 at 22:52
  • 1
    @TimHeinert Usually the tables are put in the main file, not in separate files; in any case you don't compile separately them: use \input (and the included files shouldn't have \documentclass and \begin{document}. – egreg Jan 28 '13 at 22:53
  • how could I integrate the code? I just updated the initial question – Tim Heinert Jan 28 '13 at 22:57
  • How about changing the table counter with setcounter? But I'm not sure if this is what you want – Rico Jan 28 '13 at 22:59
  • could you propose which line I would have to add to use setcounter it sounds liek a good way to do it – Tim Heinert Jan 28 '13 at 23:00
  • Why do you want to have tables in separate documents numbered as if they are in the same document? – Ian Thompson Jan 28 '13 at 23:09
  • oh..this is only because i don't know how to incorporate them into a single file – Tim Heinert Jan 28 '13 at 23:10
  • Do you want one document with multiple tables or do you want multiple documents with different table numbering (i.e. Document 1 has Table 1 and Document 2 has Table 2)? – Qrrbrbirlbel Jan 28 '13 at 23:32
  • multiple documents with single tables would be great – Tim Heinert Jan 28 '13 at 23:35
  • Then you'll need to use \setcounter, \addtocounter or \stepcounter, depending on your case. For example, in the second document, you could use \setcounter{table}{1} in the preamble or at least before the table environment. Can you describe your use-case? Maybe there is a simple one-document-multiple-tables solution that produces the same output, only needing you to split the resulting PDF. – Qrrbrbirlbel Jan 28 '13 at 23:36
  • 1
    @Tim --- I don't understand what you want. Your last comment seems to contradict the one before! – Ian Thompson Jan 28 '13 at 23:37
  • @Tim, here's a different way to ask: Would you prefer to end up with each table typeset as a separate PDF, or with a single PDF document containing all the tables? – alexis Jan 28 '13 at 23:55

2 Answers2

1

If you put two tables in the same document they will be numbered consecutively.

\documentclass{article}
\begin{document}
\begin{table}
\centering
\begin{tabular}{|c|}\hline
This is a table \\ \hline
\end{tabular}
\caption{The first table.}
\end{table}
%
\begin{table}
\centering
\begin{tabular}{|c|}\hline
This is another table \\ \hline
\end{tabular}
\caption{The second table.}
\end{table}
\end{document}

If the code gets too long, you can place everything from \begin{table} to end{table} in a separate file, say 'table1.tex' and then put \input{table1} in your main document.

Ian Thompson
  • 43,767
0

If you have good reason to keep your tables in separate files, you can fix your problem by adjusting the {table} counter, like this:

\setcounter{table}{9}
\begin{table} 
(whatever) 
\caption{This will be numbered ``Table 10.''} 
\end{table}

Note that you set it to the value it would have had before the table in question.

But do you really have good reason to keep your tables in separate documents? By doing so, you lose out on LaTeX's automatic numbering and all sorts of other goodies. If you can rearrange your workflow so that you can generate all tables in a single document, you'll be better off in the long run.

alexis
  • 7,961