
¿Puedo hacer este tipo de tabla en LaTeX?
Me gustaría aplicar las respuestas a esta tabla:
\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}
Respuesta1
Sintiendo que se parece más a una imagen, la codifiqué en 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}
Además, ¡añadir texto no puede ser más fácil!
Vea este ejemplo:
\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}
Actualizar
En cuanto a la versión editada final de la pregunta, aquí hay otra TikZ
implementación que acepta cualquier tamaño de tabla:
\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}
El primero \foreach
recorre los números impares desde 1
hasta 2*#columns-1
y el segundo \foreach
recorre los números impares desde 1
hasta 2*#rows-1
. Además, \x/6
son múltiplos del ancho de media columna y \x/24
son múltiplos del alto de media fila. Las filas de la tabla se ingresan en el \mytable
comando solo una vez.
Respuesta2
Aquí creo mi propia macro \Dcell[]
, que se utilizará como componente de un TABstack, para crear la tabla. Admito la posibilidad de agregar texto a los elementos con el argumento opcional to \Dcell
. Hay 3 parámetros de usuario en la parte superior del archivo:
\rlwd
el ancho de las reglas de las esquinas
\rlln
la longitud de las reglas de las esquinas
\cellhgap
el espacio vacío entre las dos reglas de las esquinas (el espacio vertical se ajusta automáticamente para mantener la celda cuadrada).
Obviamente, \cellhgap + 2\rlln
debe exceder la entrada de texto más amplia.
Si bien hay un poco de configuración de preámbulo, el uso real es bastante trivial.
\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}