分段表

分段表

在此輸入影像描述

我可以用 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奇數,第二個循環遍歷從到 的奇數。此外,是半列寬度的倍數,是半行高度的倍數。表行僅在命令中輸入一次。12*#columns-1\foreach12*#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}

在此輸入影像描述

相關內容