
私はこのフォーラムが本当に気に入っています。これまで何度か、読むだけで助けられました。残念ながら、私の特殊な問題に対する解決策が見つからなかったため、コミュニティに尋ねることにしました。
特別な複数行テーブルを作成するのに役立つマクロをコーディングしたいと思います。テーブル内には tikzpicture env があり、それがさらに困難になっています。
以下に小さな例を示します。
%% 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}
私の目的は、この処理につながるマクロを定義することです。
\starttable{MyyLableName}
%\addplot dummy
\finishtable{MyTableEntries}
上記の内容に基づいて、この問題を解決するためのヒントはありますか?ご返信をお待ちしております。
答え1
アップデート
環境を使用し、キー値構造を使用してプロット オプションに 1 つの引数のみを使用することをお勧めします。これにより、、、、、、およびのみを設定する固定数の引数よりも柔軟性が高まります。またxlabel
、引数ylabel
の順序を知る必要もありません。xmax
ymax
legend pos
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}
元の回答
あなたが本当に何を達成したいのかはわかりませんが、 を使用する必要はありません\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}