我可以用 LaTeX 制作这种表格吗?
我想将答案应用到这个表中:
\documentclass[10pt]{article}
\usepackage[left=1cm,right=1.5cm,top=1cm, bottom=3.5cm]{geometry}
\begin{document}
\begin{tabular}{|l|l|l|}
\hline
text & text & text \\
\hline
text & text & text \\
\hline
text & text & text \\
\hline
text & text & text \\
\hline
text & text & text \\
\hline
text & text & text \\
\hline
text & text & text \\
\hline
text & text & text \\
\hline
text & text & text \\
\hline
text & text & text \\
\hline
text & text & text \\
\hline
text & text & text \\
\hline
\end{tabular}
\end{document}
答案1
感觉它更像一张图片,我将其编码为TikZ
:
\documentclass[tikz,border=2pt]{standalone}
\usetikzlibrary{positioning,calc}
\begin{document}
\begin{tikzpicture}[tp/.style={minimum height=6cm+2\pgflinewidth,minimum width=1cm,fill=white},line width=1pt]
\node[minimum size=6cm,inner sep=0pt,draw] (big) {};
\draw (big.180)--(big.0)(big.90)--(big.-90);
\node[tp] at ($(big.center)!.5!(big.0)$) {};
\node[tp] at ($(big.center)!.5!(big.180)$) {};
\node[tp,rotate=90] at ($(big.center)!.5!(big.90)$) {};
\node[tp,rotate=90] at ($(big.center)!.5!(big.-90)$) {};
\end{tikzpicture}
\end{document}
此外,添加文本再简单不过了!
看看这个例子:
\documentclass[tikz,border=2pt]{standalone}
\usetikzlibrary{positioning,calc}
\begin{document}
\begin{tikzpicture}[BL/.style={draw=blue,line width=1cm,shorten >=-1pt,shorten <=-1pt},line width=1pt]
\node[minimum size=6cm,inner sep=0pt,draw] (big) {};
\draw (big.180)--(big.0)(big.90)--(big.-90);
\draw[BL]($(big.90)!.5!(big.135)$)--($(big.-90)!.5!(big.-135)$);
\draw[BL]($(big.90)!.5!(big.45)$)--($(big.-90)!.5!(big.-45)$);
\draw[BL]($(big.180)!.5!(big.135)$)--node[pos=.25,fill=white]{Cell no. 11}node[pos=.75,fill=white]{Cell no. 12}($(big.0)!.5!(big.45)$);
\draw[BL]($(big.180)!.5!(big.-135)$)--node[pos=.25,fill=white]{Cell no. 21}node[pos=.75,fill=white]{Cell no. 22}($(big.0)!.5!(big.-45)$);
\end{tikzpicture}
\end{document}
更新
至于问题的最终编辑版本,这里是另一个TikZ
接受任何表大小的实现:
\documentclass[10pt]{article}
\usepackage{tikz,colortbl}
\usetikzlibrary{positioning,calc}
\begin{document}
\newcommand{\mytable}[1]{\ifnum#1>0\hline\else\fi
text & text & text \\ \ifnum#1>0\hline\else\fi
text & text & text \\ \ifnum#1>0\hline\else\fi
text & text & text \\ \ifnum#1>0\hline\else\fi
text & text & text \\ \ifnum#1>0\hline\else\fi
text & text & text \\ \ifnum#1>0\hline\else\fi
text & text & text \\ \ifnum#1>0\hline\else\fi
text & text & text \\ \ifnum#1>0\hline\else\fi
text & text & text \\ \ifnum#1>0\hline\else\fi
text & text & text \\ \ifnum#1>0\hline\else\fi
text & text & text \\ \ifnum#1>0\hline\else\fi
text & text & text \\ \ifnum#1>0\hline\else\fi
text & text & text \\ \ifnum#1>0\hline\else\fi
}
\newcolumntype{W}{>{\color{white}}l}
\begin{tikzpicture}[shorten >=-1pt,shorten <=-1pt]
\node[draw,inner sep=0pt](table){%
\begin{tabular}{|W|W|W|}
\mytable{1}
\end{tabular}};
\foreach \x in {1,3,5}
\draw[white,line width=.3cm] ($(table.north west)!\x/6!(table.north east)$)--($(table.south west)!\x/6!(table.south east)$);
\foreach \x in {1,3,...,23}
\draw[white,line width=.1cm] ($(table.north west)!\x/24!(table.south west)$)--($(table.north east)!\x/24!(table.south east)$);
\setlength{\extrarowheight}{.4pt}
\node at (table.center){\noindent%
\begin{tabular}{lll}
\mytable{0}
\end{tabular}};
\end{tikzpicture}
\end{document}
第一个循环遍历从到 的\foreach
奇数,第二个循环遍历从到 的奇数。此外,是半列宽的倍数,是半行高的倍数。表格行在命令中仅输入一次。1
2*#columns-1
\foreach
1
2*#rows-1
\x/6
\x/24
\mytable
答案2
这里我创建了自己的宏\Dcell[]
,它将用作 TABstack 的组件,用于创建表格。我可以使用可选参数向元素添加文本\Dcell
。文件顶部有 3 个用户参数:
\rlwd
角规则的宽度
\rlln
角的长度规则
\cellhgap
两个角规则之间的空白间隙(垂直间隙会自动调整以保持单元格方形。
显然,\cellhgap + 2\rlln
必须超出最宽的文本条目。
尽管有一些前言设置,但实际使用却非常简单。
\documentclass{article}
\usepackage{tabstackengine}
\def\rlwd{.4pt}
\def\rlln{3ex}
\def\cellhgap{3ex}
\def\cellfield{\dimexpr\cellhgap + 2\dimexpr\rlln}
\def\cellvgap{.5\dimexpr\cellhgap-\ht\strutbox\relax}
\setstackEOL{\cr}
\setstackgap{S}{-\rlwd}
\fixTABwidth{T}
\newcommand\Dcell[1][]{\protect\Dcellraw{#1}}
\newcommand\Dcellraw[1]{%
\stackunder[\cellvgap]{%
\stackon[\cellvgap]{\makebox[\cellfield]{\strut#1}}{%
\rule[\dimexpr-\rlln+\rlwd\relax]{\rlwd}{\rlln}\rule{\rlln}{\rlwd}%
\hspace{\cellhgap}%
\rule{\rlln}{\rlwd}\rule[\dimexpr-\rlln+\rlwd\relax]{\rlwd}{\rlln}}%
}{%
\rule{\rlwd}{\rlln}\rule{\rlln}{\rlwd}%
\hspace{\cellhgap}%
\rule{\rlln}{\rlwd}\rule{\rlwd}{\rlln}%
}\kern-\dimexpr\rlwd%
}
\begin{document}
\tabbedShortstack{
\Dcell[xyz]&\Dcell\cr
\Dcell[z]&\Dcell[abcdefg]
}
\end{document}