我正在处理tabularx
在左侧单元格中排列极限图片的情况,并且想在右侧输入解决方案。
这是表格的代码,但我很难安排它,以便所有文本(和图片)从单元格顶部开始。我已经在答案中看到过,[t]
但\toprule
它似乎不起作用,或者我不知道把它放在哪里才能让它起作用。
\documentclass{article}
\usepackage[a4paper,margin=1in,landscape]{geometry}
\usepackage{tabularx}
\usepackage{multicol}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pgfplots} % for graphs
\usepackage{enumitem} %for abc lists%
\setlength{\columnsep}{1 in} % for column spacing%
\setcounter{tocdepth}{1} %for toc level --> up to and including subsections%
\raggedcolumns % to make column heights uneven
\pgfplotsset{compat=1.17}
\begin{document}
\begin{multicols*}{2}
\begin{tabularx}{0.425\textwidth}{ X X }
Above picture & Above explanation \\
A) \begin{tikzpicture}[scale=0.5] %Quad 01%
\begin{axis}[ xmin=0, xmax=3, ymin=0, ymax=3]
\draw[color=gray] (-5,0) -- (5,0);
\draw[color=gray] (0,-5) -- (0,5);
\addplot[domain=0:3, line width=5pt, samples=300] {x+1};
\filldraw[fill=white, ultra thick, line width=2pt](1,2) circle (0.1); % dot
\draw[dashed, line width=5pt, color=green] ( 0,-5 ) -- ( 0,5 ); % vertical
\draw[dashed, line width=5pt, color=green] ( -5,0 ) -- ( 5,0 ); % horizontal
\end{axis}
\end{tikzpicture}
&
Explanation line 1
Explanation line 2
\\
Below picture & Below explanation
\end{tabularx}
\end{multicols*}
\end{document}
答案1
即使 TikZ 图片不同,此解决方案也能起作用。
我使用了新的包,tabularray
因为它最容易将行文本对齐到顶部。
我已经用 为轴环境命名name = myaxis
,在低于 12pt 处创建一个坐标(没有维度)myaxis.north
(您可以使用任何您喜欢的位置):
\coordinate (mycoor) at ([yshift=-12pt]myaxis.north);
然后我使用这个坐标作为基线:baseline=(mycoor)
。
\documentclass{article}
\usepackage[a4paper,margin=1in,landscape]{geometry}
\usepackage{mwe}
\usepackage{tabularray}
\usepackage{multicol}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pgfplots} % for graphs
\usepackage{enumitem} %for abc lists%
\setlength{\columnsep}{1 in} % for column spacing%
\setcounter{tocdepth}{1} %for toc level --> up to and including subsections%
\raggedcolumns % to make column heights uneven
\pgfplotsset{compat=1.17}
\begin{document}
\begin{multicols*}{2}
\begin{tblr}{*2{X[l,h]}}
Above picture & Above explanation \\
A) \begin{tikzpicture}[scale=0.5, baseline=(mycoor)] %Quad 01%
\begin{axis}[ xmin=0, xmax=3, ymin=0, ymax=3,name = myaxis]
\draw[color=gray] (-5,0) -- (5,0);
\draw[color=gray] (0,-5) -- (0,5);
\addplot[domain=0:3, line width=5pt, samples=300] {x+1};
\filldraw[fill=white, ultra thick, line width=2pt](1,2) circle (0.1); % dot
\draw[dashed, line width=5pt, color=green] ( 0,-5 ) -- ( 0,5 ); % vertical
\draw[dashed, line width=5pt, color=green] ( -5,0 ) -- ( 5,0 ); % horizontal
\end{axis}
\coordinate (mycoor) at ([yshift=-12pt]myaxis.north);
\end{tikzpicture}
&
{Explanation line 1\\
Explanation line 2}
\\
Below picture & Below explanation
\end{tblr}
\end{multicols*}
\end{document}