セグメント化されたテーブル

セグメント化されたテーブル

ここに画像の説明を入力してください

このような表を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の奇数をループし、2 番目のループは からまでの奇数をループします。また、は列幅の半分の倍数であり、は行の高さの半分の倍数です。テーブル行はコマンドに 1 回だけ入力されます。12*#columns-1\foreach12*#rows-1\x/6\x/24\mytable

答え2

\Dcell[]ここで、テーブルを作成するために、TABstack のコンポーネントとして使用される独自のマクロ を作成します。 のオプション引数を使用して、要素にテキストを追加する可能性を認めます\Dcell。ファイルの先頭には 3 つのユーザー パラメーターがあります。

\rlwdコーナールールの幅

\rllnコーナーの長さのルール

\cellhgap2 つのコーナー ルール間の空きスペース (垂直方向のスペースはセルを正方形に保つために自動調整されます)。

明らかに、\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}

ここに画像の説明を入力してください

関連情報