
Eu realmente gosto deste fórum. Isso me ajudou algumas vezes no passado, apenas lendo. Infelizmente, para o meu problema especial não consegui encontrar nenhuma solução, então decidi perguntar à comunidade.
Gostaria de codificar uma macro que ajude a criar uma tabela multilinha especial. Dentro da mesa há um ambiente tikzpicture que torna mais difícil.
Aqui está um pequeno exemplo disso:
%% 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}
Meu objetivo é definir uma macro que levará a esse tratamento:
\starttable{MyyLableName}
%\addplot dummy
\finishtable{MyTableEntries}
com base no conteúdo acima. Você tem alguma dica para resolver esse problema? Aguardo com expectativa as suas respostas.
Responder1
Atualizar
Eu sugeriria usar ambientes e apenas um argumento para as opções de plotagem usando a estrutura de valor-chave. Isso será mais flexível do que um número fixo de argumentos definindo apenas xlabel
, ylabel
, xmax
, ymax
, legend pos
e . E você não precisa saber a ordem dos 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}
Resposta original
Não entendo o que você realmente deseja alcançar, mas não há necessidade de usar \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}