1

I am getting a compilation error when I use the package graphicx with a table that I generated from this website: https://www.tablesgenerator.com/. When I drop the \usepackage{graphicx} from the text and leave the table, the compilation works fine. On the other hand, when I take off the table and leave the \usepackage{graphicx}, the compilation also works fine. I need that both of them work together. Here is an example of the text that I am working with:

\documentclass{article}
\renewcommand{\contentsname}{Sumário}
\usepackage[utf8]{inputenc}
\usepackage{setspace}
\onehalfspacing
\usepackage{hyperref}
\hypersetup{colorlinks=true,linkcolor=[rgb]{0,0,0.6},citecolor=[rgb]{0,0,0.6},urlcolor=[rgb]{0,0,0.6}}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}
\usepackage{mathpazo}
\renewcommand{\sfdefault}{lmss}
\renewcommand{\ttdefault}{lmtt}
\usepackage{graphicx}

\title{Regulation} \author{Mateus Maciel}

\begin{document}

\maketitle

\section{Introduction}

\begin{table}[] \centering \resizebox{\textwidth}{}{% \begin{tabular}{cccc} \textbf{Variable} & \textbf{Granularity} & \textbf{Period} & \textbf{Source} \ \hline Mobile broadband connections (3G and 4G) & Municipality & 2007-2021 & Teleco \ Regulation Index & 100 most populated municipalities & 2016-2022 & Teleco \ Investment (number of antennas per provider) & Municipality & 1998-2022 & ANATEL \ Quality (internet speed) & Municipality & 2014-2022 & Ookla \ Population & Municipality & 1991-2021 & IBGE \ GDP & Municipality & 1999-2019 & IBGE \ Employment & Municipality & 1985-2020 & IBGE \ \hline \end{tabular}% } \caption{Summary of the dataset} \label{tab:my-table} \end{table}

\end{document}

  • By the way, the error is caused by the second argument of \resizebox being empty. It should have been {!} or just !. But I agree with @samcarter-is-at-topanswers-xyz that it is better not to use it. – Pieter van Oostrum Nov 16 '22 at 15:28

1 Answers1

1

Don't use \resizebox for elements which contain text. This usually gives a very poor result.

Instead you could use a table like this:

\documentclass{article}
\renewcommand{\contentsname}{Sumário}
\usepackage[utf8]{inputenc}
\usepackage{setspace}
\onehalfspacing
\usepackage{hyperref}
\hypersetup{colorlinks=true,linkcolor=[rgb]{0,0,0.6},citecolor=[rgb]{0,0,0.6},urlcolor=[rgb]{0,0,0.6}}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}
\usepackage{mathpazo}
\renewcommand{\sfdefault}{lmss}
\renewcommand{\ttdefault}{lmtt}
\usepackage{graphicx}

\title{Regulation} \author{Mateus Maciel} \usepackage{tabularx} \usepackage{booktabs}

\begin{document}

\maketitle

\section{Introduction}

\begin{table}[htbp] \begin{tabularx}{\linewidth}{@{}X>{\raggedright}p{3.5cm}ll@{}} \toprule \textbf{Variable} & \textbf{Granularity} & \textbf{Period} & \textbf{Source} \ \midrule Mobile broadband connections (3G and 4G) & Municipality & 2007-2021 & Teleco \ Regulation Index & 100 most populated municipalities & 2016-2022 & Teleco \ Investment (number of antennas per provider) & Municipality & 1998-2022 & ANATEL \ Quality (internet speed) & Municipality & 2014-2022 & Ookla \ Population & Municipality & 1991-2021 & IBGE \ GDP & Municipality & 1999-2019 & IBGE \ Employment & Municipality & 1985-2020 & IBGE \ \bottomrule \end{tabularx}% \caption{Summary of the dataset} \label{tab:my-table} \end{table}

\end{document}

enter image description here