为什么右列的内容不在顶部?我该如何将它们放在那里?我试图展示图形变换与 y=af(b(xc))+d 中 a、b、c 和 d 的值之间的对应关系。
\documentclass{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{tikz}
\pagestyle{empty}
\newcommand{\mygrid}
{
\begin{tikzpicture}[scale=0.3]
\node at (0,14) {\LARGE{Graph}};
\draw[gray] (-12,-12) grid (12,12); % faint grid lines
\draw[very thick] (0,-12)--(0,12); % x-axis
\draw[very thick] (-12,0)--(12,0); % y-axis
\end{tikzpicture}
}
\newcommand{\mytable}
{%
\LARGE Variables \& Words \par
\vspace{0.2cm}
\begin{tabular}{|l|p{3cm}|p{3cm}|} \hline
& Vertical & Horizontal \\ \hline
$\times$& $a=$ & $b=$ \\ \hline
$+$ &$c=$ &$d=$\\ \hline
\end{tabular}
}
\begin{document}
\begin{tabular}{p{9.5cm}p{9.5cm}}
\mygrid & \mytable \\ % WHY IS \MYTABLE SO LOW IN ITS CELL?
\end{tabular}
\end{document}
答案1
它是底部图形文件位于行的基线上,因此如果您希望列顶部对齐,则需要\raisebox{-\height}
在第一列中使用(加上一些调整)。换句话说:您不必将第二列向上移动,而是将第一列向下移动。
\documentclass{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{tikz}
\pagestyle{empty}
\newcommand{\mygrid}
{
\begin{tikzpicture}[scale=0.3]
\node at (0,14) {\LARGE{Graph}};
\draw[gray] (-12,-12) grid (12,12); % faint grid lines
\draw[very thick] (0,-12)--(0,12); % x-axis
\draw[very thick] (-12,0)--(12,0); % y-axis
\end{tikzpicture}
}
\newcommand{\mytable}
{%
\LARGE Variables \& Words \par
\vspace{-0.3cm}
\begin{tabular}[t]{|l|p{3cm}|p{3cm}|}
\hline
& Vertical & Horizontal \\ \hline
$\times$& $a=$ & $b=$ \\ \hline
$+$ &$c=$ &$d=$\\ \hline
\end{tabular}
}
\begin{document}
\begin{tabular}{p{9.5cm}p{9.5cm}}
\raisebox{\dimexpr-\height+3.4ex}{\mygrid} & \mytable \\ % WHY IS \MYTABLE SO LOW IN ITS CELL?
\end{tabular}
\end{document}
答案2
\documentclass{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{tikz,array}
\pagestyle{empty}
\newcommand{\mygrid}
{
\begin{tikzpicture}[scale=0.3]
\node at (0,14) {\LARGE{Graph}};
\draw[gray] (-12,-12) grid (12,12); % faint grid lines
\draw[very thick] (0,-12)--(0,12); % x-axis
\draw[very thick] (-12,0)--(12,0); % y-axis
\end{tikzpicture}
}
\newcommand{\mytable}
{%
\LARGE Variables \& Words \par
\vspace{0.2cm}
\begin{tabular}{|l|p{3cm}|p{3cm}|} \hline
& Vertical & Horizontal \\ \hline
$\times$& $a=$ & $b=$ \\ \hline
$+$ &$c=$ &$d=$\\ \hline
\end{tabular}
}
\begin{document}
\begin{tabular}{m{9.5cm}m{9.5cm}}
\mygrid & \mytable \\ % WHY IS \MYTABLE SO LOW IN ITS CELL?
\end{tabular}
\end{document}