You can't nest tikzpicture
s. Anyway, you should also fix the height and a spurious space introduced by the worldflag
package.
\documentclass[a4paper, 12pt]{article}
\usepackage{graphicx}
\usepackage{worldflags}
\usepackage{longtable}
\newcommand{\flag}[1]{%
\sbox0{\worldflag[length=22.5mm]{#1}\unskip}% \unskip fixes the spurious space
\rule{0pt}{\dimeval{\ht0+\dp\strutbox}}%
\usebox{0}%
}
\begin{document}
\section{Total patentes 2024}
\begin{longtable}[c]{|l|c|r|}
\hline País & Código & Patentes\\ \hline \endhead
\flag{AE} & Emiratos Árabes Unidos & 1 \\ \hline
\flag{AR} & Argentina (AR) & 459\\ \hline
\flag{AT} & Austria (AT) & 12\\ \hline
\flag{AU} & Australia (AU) & 31\\ \hline
\end{longtable}
\end{document}
The spurious space is at line 323 of worldflags.sty
, that should be
\end{tikzpicture}}{\relax}%
and unfortunately it misses the %
.
With a more open look:
\documentclass[a4paper, 12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[spanish]{babel}
\usepackage{worldflags}
\usepackage{longtable}
\usepackage{booktabs}
\newcommand{\flag}[1]{\worldflag[length=22.5mm]{#1}\unskip}
\begin{document}
\section{Total patentes 2024}
\begin{longtable}{@{}lcr@{}}
\toprule País & Código & Patentes\\ \midrule \endhead
\midrule \multicolumn{3}{@{}r@{}}{\itshape Continúa en la página siguiente} \endfoot
\bottomrule \endlastfoot
\flag{AE} & Emiratos Árabes Unidos & 1 \\
\flag{AR} & Argentina (AR) & 459\\
\flag{AT} & Austria (AT) & 12\\
\flag{AU} & Australia (AU) & 31\\
\flag{AE} & Emiratos Árabes Unidos & 1 \\
\flag{AR} & Argentina (AR) & 459\\
\flag{AT} & Austria (AT) & 12\\
\flag{AU} & Australia (AU) & 31\\
\flag{AE} & Emiratos Árabes Unidos & 1 \\
\flag{AR} & Argentina (AR) & 459\\
\flag{AT} & Austria (AT) & 12\\
\flag{AU} & Australia (AU) & 31\\
\flag{AE} & Emiratos Árabes Unidos & 1 \\
\flag{AR} & Argentina (AR) & 459\\
\flag{AT} & Austria (AT) & 12\\
\flag{AU} & Australia (AU) & 31\\
\end{longtable}
\end{document}