
Me gusta mucho este foro. Me ayudó varias veces en el pasado, simplemente leyendo. Lamentablemente, para mi problema especial no pude encontrar ninguna solución, así que decidí preguntar a la comunidad.
Me gustaría codificar una macro que me ayudará a crear una tabla especial de varias filas. Dentro de la mesa hay un entorno tikzpicture que lo hace más difícil.
Aquí tienes un pequeño ejemplo de ello:
%% Erläuterungen zu den Befehlen erfolgen unter
%% diesem Beispiel.
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[ngerman]{babel}
\usepackage{amsmath}
\usepackage{array}
\usepackage{multirow}
\providecommand{\tabularnewline}{\\}
\usepackage{pgfplots} % LaTeX
\usepgfplotslibrary{fillbetween}
\newcommand{\tikzheader[1]}{%
xlabel={#1},
}
% My Macro try
%\starttable{MyyLableName}
\newcommand{\starttable[1]}{%
\begin{figure}[H]
\renewcommand{\arraystretch}{1}
\begin{tabular}{|>{\centering\arraybackslash}m{0.665\textwidth}|>{\centering\arraybackslash}m{0.28\textwidth}|}
\hline
\multirow{16}[16]{*}[-1mm]{%
\begin{tikzpicture}
\begin{axis}
[
legend style={legend pos=north east, font=\footnotesize},
grid = major,
clip=false,
xmin=0,
xmax=8,
ylabel={#1},
ymin=0,
ymax=10,
y tick label style={/pgf/number format/.cd, scaled y ticks = false, set thousands separator={},fixed},
x tick label style={/pgf/number format/fixed },
height=60mm,
width=60mm
]
}}
%\finishtable{MyTableEntries}
\newcommand{\finishtable[1]}{%
\end{axis}
\end{tikzpicture}}
& #1 \\ %\cline{2-2}
& 2 \\ \cline{2-2}
& 3 \\ %\cline{2-2}
& 4 \\ \cline{2-2}
& 5 \\ %\cline{2-2}
& 6 \\ \cline{2-2}
& 7 \\ %\cline{2-2}
& 8 \\ \cline{2-2}
& 9 \\ %\cline{2-2}
& 10 \\ \cline{2-2}
& 11 \\ %\cline{2-2}
& 12 \\ \cline{2-2}
& 13 \\ %\cline{2-2}
& 14 \\ \cline{2-2}
& 15 \\ %\cline{2-2}
& 16\\ \cline{2-2}
& 17 \\ \hline
\end{tabular}
\caption{Caption}
\end{figure}
}
\begin{document}
\section{Original table}
\begin{figure}[H]
\renewcommand{\arraystretch}{1}
\begin{tabular}{|>{\centering\arraybackslash}m{0.665\textwidth}|>{\centering\arraybackslash}m{0.28\textwidth}|}
\hline
\multirow{16}[16]{*}[-1mm]{%
\begin{tikzpicture}
\begin{axis}
[
legend style={legend pos=north east, font=\footnotesize},
grid = major,
clip=false,
xmin=0,
xmax=8,
ylabel={test},
ymin=0,
ymax=10,
y tick label style={/pgf/number format/.cd, scaled y ticks = false, set thousands separator={},fixed},
x tick label style={/pgf/number format/fixed },
height=60mm,
width=60mm
]
%%% black
%\addplot Dummy
%%%
\end{axis}
\end{tikzpicture}}
& 1 \\ %\cline{2-2}
& 2 \\ \cline{2-2}
& 3 \\ %\cline{2-2}
& 4 \\ \cline{2-2}
& 5 \\ %\cline{2-2}
& 6 \\ \cline{2-2}
& 7 \\ %\cline{2-2}
& 8 \\ \cline{2-2}
& 9 \\ %\cline{2-2}
& 10 \\ \cline{2-2}
& 11 \\ %\cline{2-2}
& 12 \\ \cline{2-2}
& 13 \\ %\cline{2-2}
& 14 \\ \cline{2-2}
& 15 \\ %\cline{2-2}
& 16\\ \cline{2-2}
& 17 \\ \hline
\end{tabular}
\caption{Caption}
\end{figure}
\section{table as Macro with error}
\starttable{MyyLableName}
%\addplot dummy
\finishtable{MyTableEntries}
\end{document}
Mi objetivo es definir una macro que conducirá a este manejo:
\starttable{MyyLableName}
%\addplot dummy
\finishtable{MyTableEntries}
basado en el contenido anterior. ¿Tiene alguna sugerencia para resolver este problema? Espero sus respuestas.
Respuesta1
Actualizar
Sugeriría usar entornos y solo un argumento para las opciones de trama usando la estructura clave-valor. Eso será más flexible que un número fijo de argumentos configurando solo xlabel
, ylabel
, xmax
, ymax
, legend pos
y . Y no es necesario conocer el orden de los argumentos.width
height
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[ngerman]{babel}
\usepackage{amsmath}
\usepackage{array}
\usepackage{float}% <- added
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}% <- added
\newcommand\MyTableCaption{}% initialize the command
\newenvironment{MyTable}[1]
{%
\def\MyTableCaption{#1}% save the option
\begin{figure}[H]
\renewcommand{\arraystretch}{1}
\begin{tabular}{|@{}c@{}|@{}c@{}|}
\hline
}
{%
\\ \hline
\end{tabular}
\caption{\MyTableCaption}
\end{figure}%
}
\newenvironment{MyTablePlot}[1]
{%
\begin{tabular}{p{0.68\textwidth}}
\centering
\begin{tikzpicture}
\begin{axis}
[
legend style={legend pos=north east, font=\footnotesize},
grid = major,
clip=false,
xmin=0,
xmax=8,
ymin=0,
ymax=10,
y tick label style={/pgf/number format/.cd, scaled y ticks = false, set thousands separator={},fixed},
x tick label style={/pgf/number format/fixed },
height=60mm,
width=60mm,
#1
]
}
{%
\end{axis}
\end{tikzpicture}
\end{tabular}%
}
\newenvironment{MyTableValues}
{\begin{tabular}{p{0.28\textwidth}}}
{\end{tabular}}
\newcommand\starttable[1]
{%
\begin{figure}[H]
\renewcommand{\arraystretch}{1}
\begin{tabular}{|@{}c@{}|@{}c@{}|}
\hline
\begin{tabular}{p{0.66\textwidth}}
\centering
\begin{tikzpicture}
\begin{axis}
[
legend style={legend pos=north east, font=\footnotesize},
grid = major,
clip=false,
xmin=0,
xmax=8,
ylabel={#1},
ymin=0,
ymax=10,
y tick label style={/pgf/number format/.cd, scaled y ticks = false, set thousands separator={},fixed},
x tick label style={/pgf/number format/fixed },
height=60mm,
width=60mm
]
}
\begin{document}
\section{A Table}
\begin{MyTable}{Caption for this Table}
\begin{MyTablePlot}
{
ylabel={y label},
xlabel={x label},
xmin=-2,
domain=-2:10,
clip=true
}
\addplot[red]{x};
\end{MyTablePlot}
&
\begin{MyTableValues}
1\\
2 \\ \hline
3 \\
4 \\ \hline
5 \\
6 \\ \hline
7 \\
8 \\ \hline
9 \\
10 \\ \hline
11 \\
12 \\ \hline
13 \\
14 \\ \hline
15 \\
16\\ \hline
17
\end{MyTableValues}
\end{MyTable}
\end{document}
Respuesta original
No entiendo qué es lo que realmente quieres lograr, pero no es necesario usarlo \multirow
.
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[ngerman]{babel}
\usepackage{amsmath}
\usepackage{array}
\usepackage{multirow}
\usepackage{float}% <- added
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}% <- added
\newcommand\starttable[1]
{%
\begin{figure}[H]
\renewcommand{\arraystretch}{1}
\begin{tabular}{|@{}c@{}|@{}c@{}|}
\hline
\begin{tabular}{p{0.68\textwidth}}
\centering
\begin{tikzpicture}
\begin{axis}
[
legend style={legend pos=north east, font=\footnotesize},
grid = major,
clip=false,
xmin=0,
xmax=8,
ylabel={#1},
ymin=0,
ymax=10,
y tick label style={/pgf/number format/.cd, scaled y ticks = false, set thousands separator={},fixed},
x tick label style={/pgf/number format/fixed },
height=60mm,
width=60mm
]
}
\newcommand\finishtable[1]
{%
\end{axis}
\end{tikzpicture}
\end{tabular}
&
\begin{tabular}{p{0.28\textwidth}}
#1
\end{tabular}\\ \hline
\end{tabular}
\caption{Caption}
\end{figure}
}
\begin{document}
\section{Original table}
\begin{figure}[H]
\renewcommand{\arraystretch}{1}
\begin{tabular}{|>{\centering\arraybackslash}m{0.665\textwidth}|>{\centering\arraybackslash}m{0.28\textwidth}|}
\hline
\multirow{16}[16]{*}[-1mm]{%
\begin{tikzpicture}
\begin{axis}
[
legend style={legend pos=north east, font=\footnotesize},
grid = major,
clip=false,
xmin=0,
xmax=8,
ylabel={test},
ymin=0,
ymax=10,
y tick label style={/pgf/number format/.cd, scaled y ticks = false, set thousands separator={},fixed},
x tick label style={/pgf/number format/fixed },
height=60mm,
width=60mm
]
%%% black
%\addplot Dummy
%%%
\end{axis}
\end{tikzpicture}}
& 1 \\ %\cline{2-2}
& 2 \\ \cline{2-2}
& 3 \\ %\cline{2-2}
& 4 \\ \cline{2-2}
& 5 \\ %\cline{2-2}
& 6 \\ \cline{2-2}
& 7 \\ %\cline{2-2}
& 8 \\ \cline{2-2}
& 9 \\ %\cline{2-2}
& 10 \\ \cline{2-2}
& 11 \\ %\cline{2-2}
& 12 \\ \cline{2-2}
& 13 \\ %\cline{2-2}
& 14 \\ \cline{2-2}
& 15 \\ %\cline{2-2}
& 16\\ \cline{2-2}
& 17 \\ \hline
\end{tabular}
\caption{Caption}
\end{figure}
\section{table as Macro with error}
\starttable{MyyLableName}
%\addplot dummy
\finishtable{%
1\\
2 \\ \hline
3 \\
4 \\ \hline
5 \\
6 \\ \hline
7 \\
8 \\ \hline
9 \\
10 \\ \hline
11 \\
12 \\ \hline
13 \\
14 \\ \hline
15 \\
16\\ \hline
17
}
\end{document}