0

I currently use a straightforward solution to get captions inside the table. However it does not allow the tables to be listed in the "\listoftables": Example: enter image description here
and the code:

\documentclass[12pt,a4paper]{article}

\begin{document}

\begin{table}
\refstepcounter{table} \label{mytable}
\begin{tabular}{|c|}
\hline
Table \ref{mytable}: The test table\\\hline
contents\\\hline
\end{tabular}
\end{table}

\listoftables

\end{document}

Is there a way to get \listoftables working with my solution?
Thank you for any ideas

0

It's relatively easy. Look at the aux file to see how a normal caption does it.

\documentclass[12pt,a4paper]{article}

\begin{document}

\begin{table}
\refstepcounter{table} \label{mytable}
\addcontentsline{lot}{table}{\string\numberline{\thetable}{The test table}}%
\begin{tabular}{|c|}
\hline
Table \thetable: The test table\\\hline
contents\\\hline
\end{tabular}
\end{table}

\listoftables

\end{document}
  • Thank you very much, great solution! For future reference, which aux file did you check to find this? – utack Jul 14 '18 at 8:35
  • Every time you run LaTeX you generate an aux file (same name as the PDF or log file but with a different extension). You can find the default \caption code in source2e.pdf from ctan. – John Kormylo Jul 14 '18 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.