# Dots until page numbers in TOC, List of tables/ figures/

Is there a way to have the dots in the list of tables (in my case) that reach until the page numbers? I have the case, that I have some tables in appendix which starts around page 35 in roman numbering (due to long TOC, lists of figures, bibliography etc). In order to have the page numbers properly aligned right, I added

\makeatletter
\renewcommand{\@pnumwidth}{45pt}
\makeatother


However, I have large gaps between the dots and the latin numbers.

\documentclass{article}
\makeatletter
\renewcommand{\@pnumwidth}{45pt}% 40pt is just an example
\makeatother

\begin{document}
\listoftables

\section{Main text}
\begin{table}[h]
\centering
\caption{Table in main text}
\begin{tabular}{|c|c|}
\hline
12 & 2 \\
\hline
3 & 42 \\
\hline
\end{tabular}
\end{table}
\clearpage

\pagenumbering{Roman}
\setcounter{page}{37}

\section{Appendix}

\begin{table}[h]
\centering
\caption{Table in appendix}
\begin{tabular}{|c|c|}
\hline
12 & 2 \\
\hline
3 & 42 \\
\hline
\end{tabular}
\end{table}
\end{document}


## 2 Answers

possibly it's cheating but you can abuse the syntax so the numbers are not in the fixed width box

\documentclass{article}
\makeatletter
\renewcommand{\@pnumwidth}{0pt{}}% 40pt is just an example
\makeatother

\begin{document}
\listoftables

\section{Main text}
\begin{table}[h]
\centering
\caption{Table in main text}
\begin{tabular}{|c|c|}
\hline
12 & 2 \\
\hline
3 & 42 \\
\hline
\end{tabular}
\end{table}
\clearpage

\pagenumbering{Roman}
\setcounter{page}{37}

\section{Appendix}

\begin{table}[h]
\centering
\caption{Table in appendix}
\begin{tabular}{|c|c|}
\hline
12 & 2 \\
\hline
3 & 42 \\
\hline
\end{tabular}
\end{table}
\end{document}


You can change the value only for the appendix:

\documentclass{article}
\makeatletter
\newcommand\changedots{}
\DeclareRobustCommand\changedots{%
\renewcommand{\@pnumwidth}{45pt}}% 40pt is just an example
\makeatother

\begin{document}
\listoftables

\section{Main text}
\begin{table}[h]
\centering
\caption{Table in main text}
\begin{tabular}{|c|c|}
\hline
12 & 2 \\
\hline
3 & 42 \\
\hline
\end{tabular}
\end{table}
\clearpage

\pagenumbering{Roman}
\setcounter{page}{37}

\section{Appendix}

\addtocontents{lot}{\changedots}

\begin{table}[h]
\centering
\caption{Table in appendix}
\begin{tabular}{|c|c|}
\hline
12 & 2 \\
\hline
3 & 42 \\
\hline
\end{tabular}
\end{table}
\end{document}