1

I tried to reference a sidewaystable in my text. Unfortunately, the reference in the text is exactly the label name, i.e. table:1 instead of just 1. How can I reference the sidewaystable below and get the table number in the text?

enter image description here

\documentclass{article}

\usepackage{tablefootnote}
\usepackage{copyrightbox}
\usepackage{graphicx}
\usepackage{float}
\usepackage{adjustbox}
\usepackage{rotating}
\begin{document}

 \begin{sidewaystable}[!htbp] \centering 
  \caption{Regression results} 
  \label{table:1}
\begin{adjustbox}{width=0.9\textwidth}
 \makeatletter
\renewcommand{\CRB@setcopyrightfont}{%
\footnotesize
\color{black}}
\makeatother
\copyrightbox [b] {
\begin{tabular}{@{\extracolsep{5pt}}lD{.}{.}{-3} D{.}{.}{-3} D{.}{.}{-3}} 
\\[-1.8ex]\hline 
bla bla & bla bla & bla bla & bla bla \\
\end{tabular}
}{source: own representation}
\end{adjustbox}
\end{sidewaystable}

\end{document}
6
  • 2
    Please post a complete minimal working example, Your code uses nonstandard commands and column specifiers and it's hard to figure out how they're defined or what packages they come from, so I can't test your code.
    – frabjous
    Commented May 19, 2022 at 18:04
  • 1
    You added some packages. That's a good first step. But that's not all of them, as the rotating package is not there, and we still don't know how you're defining those custom column specifiers. Your code needs to be a complete document that compiles as is and shows the problem. Please test before posting.
    – frabjous
    Commented May 19, 2022 at 18:13
  • @frabjous Thank you for your feedback and I'm very sorry for the confusing/unclear question. I think that it might be a package in the preamble that hinders the correct referencing of my table in the text because I tested the code above with the rotating packaging and it worked fine. Unfortunately, I have so many /usepackages in my preamble that I'll probably have to go one by one until I find out the one that I have to remove. Sorry for wasting your time.
    – TFT
    Commented May 19, 2022 at 18:20
  • 2
    Sounds like you're going about it the right way. If you figure out which package it is, and you still can't figure out why, do update your question.
    – frabjous
    Commented May 19, 2022 at 18:24
  • @frabjous I've just found out that the problem was caused by \usepackage{subfig}. After removing it from the preamble, the table cross-referencing works perfectly. I'm wondering if there is a better general approach to quickly check which code in the preamble might be the cause for compiling issues ...
    – TFT
    Commented May 19, 2022 at 18:33

1 Answer 1

1

Welcome to TeX.SE!

Your preamble should be:

\documentclass{article}
\usepackage{copyrightbox}
\usepackage{graphicx}
\usepackage{float}
\usepackage{adjustbox}
\usepackage{rotating}  
\usepackage{dcolumn}       % <--- added
\usepackage{tablefootnote} % moved here (must be after `rotating`)

\begin{document}
% table body
\end{document}

With it I can compile your MWE without any errors, warnings or bad boxes. The referencing also works correctly

Note: it is important the package loading order.

You must log in to answer this question.

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