
저는 이 포럼을 정말 좋아합니다. 예전에는 읽는 것만으로도 도움이 된 적이 몇 번 있었습니다. 안타깝게도 내 특별한 문제에 대한 해결책을 찾을 수 없어서 커뮤니티에 물어보기로 결정했습니다.
특별한 다중 행 테이블을 생성하는 데 도움이 되는 매크로를 코딩하고 싶습니다. 테이블 내부에는 더 어렵게 만드는 tikzpicture 환경이 있습니다.
다음은 이에 대한 작은 예입니다.
%% 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
업데이트
키-값-구조를 사용하는 플롯 옵션에 대해 환경과 하나의 인수만 사용하는 것이 좋습니다. 이는 고정된 개수의 인수를 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}