0

In my report, I would like to add a table and be able to refer to it in my text.

I did the following:

\begin{table}[ht]
    \centering
    \begin{tabular}{c | c | c }
        \hline
        Training Data Duration [s] & Maximum SIR [dB] & Maximum SDR [dB] \\ \hhline{|=|=|=|}
        15 & 14.4353 & \textcolor[rgb]{1,0,0}{8.7172}\\ \hline
        25 & 14.4015 & 8.7312 \\ \hline 
        35 & \textcolor[rgb]{1,0,0}{14.2806} & 8.8179 \\ \hline
        45 & 14.4674 & 9.3875 \\ \hline
        55 & 14.3881 & 9.2663 \\ \hline
        65 & 14.3003 & 9.3346 \\ \hline
        75 & \textcolor[rgb]{0,0.58,0}{14.6173} & \textcolor[rgb]{0,0.58,0}{9.4663} \\ \hline
        85 & 14.5579 & 9.1584 \\ \hline
        \hline
    \label{tab:maxsirsdr}
    \caption{Maximum SIR/SDR values for different training data durations.}
    \end{tabular}
\end{table}

I use TeXnicCenter and the LaTeX -> PS -> PDF mode with TeXLive. Without the table environment, I get the PDF in a couple of seconds. Now it does not compile at all.

What can I do? If you need more info, please ask me! And I'm sorry for abusing LaTeX terminology, my LaTeX knowledge is very basic.

2
  • Welcome to TeX - LaTeX! What is written in the .log file? Incidentally note the \label command should be after \caption Commented May 10, 2017 at 9:30
  • Philipp's suggestion did the trick, the problem was that I've put my label and my caption into the tabular environment
    – Dmitrii C.
    Commented May 10, 2017 at 9:38

1 Answer 1

1

You have to put the label and caption after the tabular environment.

\end{tabular}
\caption{Maximum SIR/SDR values for different training data durations.\label{tab:maxsirsdr}}

To be sure also put the label inside the caption so the counter which the label refers to is really the one of the caption and not something else.

Edit: Bernard has a good point in the comments about the location of captions. It is actually preferred to have the caption above the table and not below. For an explanation you can see this answer.

6
  • That did the trick! Thank you, despair has already started to kick in! And thanks for the label hint!
    – Dmitrii C.
    Commented May 10, 2017 at 9:35
  • 1
    You can put the label also immediately after the caption.
    – CarLaTeX
    Commented May 10, 2017 at 9:36
  • @CarLaTeX You are right. It is just one of my preferences to put it inside the caption.
    – Philipp
    Commented May 10, 2017 at 9:37
  • 2
    The typographic norm for tables is to have the caption before the table (because tables can stretch over several pages). But in any case, the label must follow the caption.
    – Bernard
    Commented May 10, 2017 at 9:58
  • @CarLaTeX in is better than after Commented May 10, 2017 at 11:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .