I have set up a a tabular environment and inside of it a tikzpicture. How can I adjust the width to the table cell?
\documentclass[a4paper,12pt]{article} % DIN A4
\usepackage[a4paper, portrait, top=25mm, bottom=20mm, right=25mm, left=25mm]{geometry} % Seitenränder
\usepackage{amssymb, amsmath} % Mathematische Symbole
\usepackage{tabularx} % Tabellen
\usepackage{pgfplots} % Funktionsgraph
\pgfplotsset{compat = newest}
\pagenumbering{gobble}
\title{Exponential- und Logartihmusfunktion im Vergleich}
\author{me}
\begin{document}
\maketitle
\noindent\begin{tabularx}{\textwidth}{|X|X|}
\hline
\begin{tikzpicture}
\begin{axis}[xmin = -10, xmax = 10, ymin = -10, ymax = 10, xtick distance = 2, ytick distance = 2, xticklabel=\empty,yticklabel=\empty, grid = both, minor tick num = 1, major grid style = {lightgray}, minor grid style = {lightgray!25}, width = 0.5\textwidth, height = 0.5\textwidth,axis lines = middle,xlabel=$x$,ylabel=$y$, legend style={at={(0.025,0.025)},anchor=south west}, legend cell align={left}]
\addplot[domain = -10:10, samples = 200,smooth,thick,blue,grid=major] {2^x)};
\addplot[domain = -10:10, samples = 200,smooth,thin,black,grid=major] {x};
\addlegendentry{$2^x$}
\addlegendentry{$x$}
\end{axis}
\end{tikzpicture}
&
\begin{tikzpicture}
\begin{axis}[xmin = -10, xmax = 10, ymin = -10, ymax = 10, xtick distance = 2, ytick distance = 2, xticklabel=\empty,yticklabel=\empty, grid = both, minor tick num = 1, major grid style = {lightgray}, minor grid style = {lightgray!25}, width = 0.5\textwidth, height = 0.5\textwidth,axis lines = middle,xlabel=$x$,ylabel=$y$, legend style={at={(0.025,0.025)},anchor=south west}, legend cell align={left}]
\addplot[domain = -10:10, samples = 200,smooth,thick,red,grid=major] {log2(x))};
\addplot[domain = -10:10, samples = 200,smooth,thin,black,grid=major] {x};
\addlegendentry{$log_2(x)$}
\addlegendentry{$x$}
\end{axis}
\end{tikzpicture}\
\hline
\end{tabularx}
\end{document}
side question: Why do I have to use X for \begin{tabularx}{\textwidth}{|X|X|}?







groupplotsfrompgfplotsinstead of atabular. – Apr 02 '21 at 23:29