I'm trying to figure out how to insert a resize command inside a table environment in org-mode that exports to latex,
Here is my minimal example of raw latex source vs org-mode tables:
#+LATEX_CLASS: article
#+LATEX_HEADER: \usepackage{graphicx}
#+begin_src latex :exports results :results latex
\begin{table}
\caption{a table that scales to the linewidth}
\centering
\resizebox{\linewidth}{!}{%
\begin{tabular}{ll}
A & 1\\
B & 2\\
\end{tabular}}
\label{tab:scaled}
\end{table}
#+end_src
How can I make org-mode tables with a \resizebox{\linewidth}{!}{% }
command so that the same result is achieved for the table below? (Or alternatively something else that gives the same result).
#+LATEX_CLASS: article
#+LATEX_HEADER: \usepackage{graphicx}
#+CAPTION: a table that does not scale to the linewidth
#+LABEL: tab:uncaled
| A | 1 |
| B | 2 |
My attempt based on the LaTeX-specific-attributes from org-mode manual
#+LATEX_CLASS: article
#+LATEX_HEADER: \usepackage{graphicx}
#+CAPTION: a table that does not scale to the linewidth
#+ATTR_LATEX: :math-prefix \resizebox{\linewidth}{!}{% :math-suffix }
| A | 1 |
| B | 2 |
However the things I've tried has not worked. In the answer provided to the question on tex.stackechange another alternative is presented, which requires insertion of another environment between table and tabular.
#+LATEX_CLASS: article
#+LATEX_HEADER: \usepackage{graphicx}
#+LATEX_HEADER: \usepackage{adjustbox}
#+begin_src latex :exports results :results latex
\begin{table}
\caption{a table that scales to the linewidth}
\centering
\begin{adjustbox}{width=\textwidth}
\begin{tabular}{ll}
A & 1\\
B & 2\\
\end{tabular}
\end{adjustbox}
\label{tab:scaled}
\end{table}
#+end_src