问题:
我从网上准备了一个表格。问题是它不适合这个页面。第二个问题是我添加了一个图形的代码,我想把这个图形添加到第一列(第二个单元格)。有人能帮我吗?如何增加单元格的高度以实现居中对齐?
平均能量损失
\documentclass[12pt]{article}
\usepackage[bindingoffset=0.2in,left=0.5in,right=0.5in,top=0.5in,bottom=0.5in,footskip=.25in]{geometry}
\usepackage[centertags]{amsmath}
\usepackage{latexsym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{newlfont}
\usepackage{enumerate}
\usepackage{makeidx}
\usepackage{tikz}
\usepackage{multirow}
\usetikzlibrary{arrows.meta}
\usepackage{xparse}
\usetikzlibrary{backgrounds,intersections}
\begin{document}
%%%%%%%%%% Table %%%%%%%%%%%%%%%%
\begin{table}[]
\begin{tabular}{|l|cccc|}
\hline
\multicolumn{1}{|c|}{\multirow{2}{*}{\textbf{Set}}} & \multicolumn{4}{c|}{\textbf{Closure Property}} \\ \cline{2-5}
\multicolumn{1}{|c|}{} & \multicolumn{1}{c|}{\textbf{Operation}} & \multicolumn{1}{c|}{\textbf{Y/N}} & \multicolumn{1}{c|}{\textbf{Result}} & \textbf{Remarks or Justification} \\ \hline
\multirow{4}{*}{\textbf{Natural Numbers}} & \multicolumn{1}{c|}{Addition} & \multicolumn{1}{c|}{Yes} & \multicolumn{1}{c|}{Natural number $+$ Natural number $=$ Natural number} & \\ \cline{2-5}
& \multicolumn{1}{c|}{Subtraction} & \multicolumn{1}{c|}{No} & \multicolumn{1}{c|}{Natural number $-$ Natural number $\neq$ Natural number} & $2-5=-3$ and $-3$ is not a natural number \\ \cline{2-5}
& \multicolumn{1}{c|}{Multiplication} & \multicolumn{1}{c|}{Yes} & \multicolumn{1}{c|}{Natural number $\times$ Natural number $=$ Natural number} & \\ \cline{2-5}
& \multicolumn{1}{c|}{Division} & \multicolumn{1}{c|}{No} & \multicolumn{1}{c|}{Natural number $\div$ Natural number $\neq$ Natural number} & $2\div 5$, which is not a Natural number \\ \hline
\end{tabular}
\end{table}
%%%%%%%%%% Figure %%%%%%%%%%%%%%%%
\begin{center}
\begin{tikzpicture}[
scale=1.5,
transform shape,
txt/.style={align=center,font=\bfseries\sf\tiny},
]
\foreach \x/\clr in {1/blue!20}
\draw[color=black,very thick,fill=\clr] (0,\x) circle [radius=\x];
\node[txt] at (0,1) {Natural Numbers\\\\1, 2, 3, \dots};
\end{tikzpicture}
\end{center}
\end{document}
答案1
和tabularray
:
\documentclass[12pt]{article}
\usepackage[bindingoffset=0.2in,left=0.5in,right=0.5in,top=0.5in,bottom=0.5in,footskip=.25in]{geometry}
\usepackage[centertags]{amsmath}
\usepackage{latexsym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{newlfont}
\usepackage{enumerate}
\usepackage{makeidx}
\usepackage{tikz}
\usepackage{multirow}
\usetikzlibrary{arrows.meta}
\usepackage{xparse}
\usetikzlibrary{backgrounds,intersections}
\usepackage{tabularray}
\begin{document}
\begin{table}
\begin{tblr}{
colspec={Q[l,m]Q[c,m]Q[c,m]X[c,m]X[c,m]},
hlines, vlines,
row{1,2}={font=\bfseries},
cell{3,5}{3}={green},
cell{4,6}{3}={red},
}
\SetCell[r=2]{c}Set & \SetCell[c=4]{c,red} Closure Property &&& \\
& Operation & Y/N & Result & Remarks or Justification \\
\SetCell[r=4]{c}{Natural Numbers\\[7pt]
\begin{tikzpicture}[
scale=1.5,
transform shape,
txt/.style={align=center,font=\bfseries\sf\tiny},
]
\foreach \x/\clr in {1/blue!20}
\draw[color=black,very thick,fill=\clr] (0,\x) circle [radius=\x];
\node[txt] at (0,1) {Natural Numbers\\\\1, 2, 3, \dots};
\end{tikzpicture}} & Addition & Yes & Natural number $+$ Natural number $=$ Natural number & \\
& Subtraction & No & Natural number - Natural number $\neq$ Natural number & $2-5=-3$ and $-3$ is not a Natural number \\
& Multiplication & Yes & Natural number $\times$ Natural number $=$ Natural number & \\
& Division & No & Natural number $\div$ Natural number $\neq$ Natural number & $2\div 5$, which is not a Natural number \\
\end{tblr}
\end{table}
\end{document}
答案2
编辑:将数字放入表格中。
- 正如@samcarter 注意到的:删除这些
\multicolumn{1}
东西。 - 使用 \small 使文本稍微小一点。
- 在第四列中用缩写替换
Natural Number
,因为它占用了太多空间。否则,您将永远无法将表格调整到适合您的文本宽度(除非您在这一列中换行,但我认为这一点也不好)。不过,这是您的选择。 - 用来
tabularx
将最后一列放入可用空间中。或者,如果您想将全文保留在第四列中,X
也可以在那里使用一列。 - 我对图片使用了 `\multirow{6},因为它实际上跨越 6 行。
经过一些小的调整,它变成:
\documentclass[12pt]{article}
\usepackage[bindingoffset=0.2in,left=0.5in,right=0.5in,top=0.5in,bottom=0.5in,footskip=.25in]{geometry}
\usepackage[centertags]{amsmath}
\usepackage{latexsym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{newlfont}
\usepackage{enumerate}
\usepackage{makeidx}
\usepackage{tikz}
\usepackage{multirow}
\usepackage{tabularx}
\usetikzlibrary{arrows.meta}
\usepackage{xparse}
\usetikzlibrary{backgrounds,intersections}
\begin{document}
%%%%%%%%%% Table %%%%%%%%%%%%%%%%
\begin{table}[]
\small
\setlength\extrarowheight{2pt}
\begin{tabularx}{\textwidth}{|@{\,}c@{\,}|c|c|c|>{\raggedright\arraybackslash}X|}
\hline
\multirow{2}{*}{\textbf{Set}} & \multicolumn{4}{c|}{\textbf{Closure Property}} \\ \cline{2-5}
& \textbf{Operation} & \textbf{Y/N} & \textbf{Result} & \textbf{Remarks or Justification} \\ \hline
\multirow{6}{*}{%
\begin{tikzpicture}[
scale=1.5,
transform shape,
txt/.style={align=center,font=\bfseries\sf\tiny},
]
\foreach \x/\clr in {1/blue!20}
\draw[color=black,very thick,fill=\clr] (0,\x) circle [radius=\x];
\node[txt] at (0,1) {Natural Numbers\\\\1, 2, 3, \dots};
\end{tikzpicture}}
& Addition & Yes & NatNum $+$ NatNum $=$ NatNum & \\ \cline{2-5}
& Subtraction & No & NatNum $-$ NatNum $\neq$ NatNum & $2-5=-3$ and $-3$ is not a natural number \\ \cline{2-5}
& Multiplication & Yes & NatNum $\times$ NatNum $=$ NatNum & \\ \cline{2-5}
& Division & No & NatNum $\div$ NatNum $\neq$ NatNum & $2\div 5$, which is not a natural number \\ \hline
\end{tabularx}
\end{table}
\end{document}