0

I have the following code running in overleaf using pdfLaTeX

\begin{table}[htbp]
\centering
\caption{$C_2$ matrix}
\[
\begin{array}{|c|c|c|c|c|}
\hline
C_2 & \texttt{L1} & \texttt{L2} & \texttt{L3} & \texttt{L4} \\ \hline
\texttt{L1} & \textbf{0.6} & 0.133 & 0.133 & 0.133 \\ \hline
\texttt{L2} & 0.133 & \textbf{0.6} & 0.133 & 0.133 \\ \hline
\texttt{L3} & 0.133 & 0.133 & \textbf{0.6} & 0.133 \\ \hline
\texttt{L4} & 0.133 & 0.133 & 0.133 & \textbf{0.6} \\ \hline
\end{array}
\]
\end{table}

that produces the following output but without the desired caption.

enter image description here

How can I fix that? Thanks.

7
  • 7
    If the caption is not showing that is due to some code you have not shown. Please fix your example to be a complete small document that shows the problem, then someone will be able to debug it. Jul 12, 2021 at 16:08
  • Welcome to TeX.SE.
    – Mico
    Jul 12, 2021 at 17:04
  • 1
    If I make your code minimally compilable by prefixing it with \documentclass{article} \begin{document} and affixing \end{document} to it, the caption shows up just fine. It's important that you provide all information needed to enable readers to replicate (and, next, diagnose and solve) the issue you say you've come across.
    – Mico
    Jul 12, 2021 at 17:06
  • Please do show us the 4 or 5 lines of code in your document that precede \begin{table}.
    – Mico
    Jul 12, 2021 at 17:13
  • BTW, \centering has no effect on either \caption or displayed math. Both are already centered. Jul 13, 2021 at 0:31

1 Answer 1

5

I cannot reproduce your picture. Below is what I tried at overleaf using pdflatex

\documentclass{article}
\begin{document}
\begin{table}[htbp]
\centering
\caption{$C_2$ matrix}
\[
\begin{array}{|c|c|c|c|c|}
\hline
C_2 & \texttt{L1} & \texttt{L2} & \texttt{L3} & \texttt{L4} \\ \hline
\texttt{L1} & \textbf{0.6} & 0.133 & 0.133 & 0.133 \\ \hline
\texttt{L2} & 0.133 & \textbf{0.6} & 0.133 & 0.133 \\ \hline
\texttt{L3} & 0.133 & 0.133 & \textbf{0.6} & 0.133 \\ \hline
\texttt{L4} & 0.133 & 0.133 & 0.133 & \textbf{0.6} \\ \hline
\end{array}
\]
\end{table}
\end{document}

enter image description here

2
  • Thanks for the answer. As it turns out the problem was due to some lines I had copy pasted in the beginning of my document that messed up image and table captions.
    – Da Mike
    Jul 15, 2021 at 11:44
  • @DaMike, you are welcome. Happy to know that your found the answer.
    – citsahcots
    Jul 15, 2021 at 11:45

You must log in to answer this question.

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