7

everyone. I'm currently beginning to use LaTeX technology and stumbled upon this problem, I have read several tabular manuals on CTAN with no success.

I'm trying to create a table like this:

    +---------+--------+--------+--------+
    |     |114|    |100|    |92 |    |101|
    |     |___|    |___|    |___|    |___|
    |         |        |        |        |
    | 113     | 99     | 84     | 97     |
    +---------+--------+--------+--------+
    |     |114|    |100|    |92 |    |101|
    |     |___|    |___|    |___|    |___|
    |         |        |        |        |
    | 113     | 99     | 84     | 97     |
    +---------+--------+--------+--------+
    |     |114|    |100|    |92 |    |101|
    |     |___|    |___|    |___|    |___|
    |         |        |        |        |
    | 113     | 99     | 84     | 97     |
    +---------+--------+--------+--------+

Is there any existing package to achieve this structure? If not, I was thinking about nesting rows or something like that, though I'm not sure yet.

11

A solution with Plain TeX for fun, learning, and to show what's possible with the basic building blocks:

\def\widest{000}
\def\uv{\unskip\vrule}
\def\bx#1#2{\vbox{%
  \offinterlineskip%
  \halign{\ \hfil## &##&\ \hfil## \cr
    \hphantom{\widest}&&\hphantom{\widest}\cr
    &\vrule\strut& #2\cr
    \omit&\hrulefill&\omit\hrulefill\cr
    #1&\strut&\cr}
}}
\def\bxx{
  \bx{113}{114} & 
  \bx{99}{100} & 
  \bx{84}{92} & 
  \bx{97}{101}\cr
  \noalign{\hrule}
}

{\offinterlineskip
\halign{\vrule\strut \hfill #\uv & #\uv & #\uv & #\uv\cr
\noalign{\hrule}
\bxx\bxx\bxx
}}\bye

enter image description here

|improve this answer|||||
  • 2
    TeXnicians: this is the first table I've ever created in Plain TeX; please go easy on me if I've committed any cardinal sins! – Paul Gessler Apr 22 '15 at 23:39
  • Doing it the hard way again ;-) (+1) – user31729 Apr 23 '15 at 4:11
  • 1
    +1 I added a second plain TeX solution here. We can see, that plain TeX solutions are more simple than LaTeX. The reason is that LaTeX doesn't give any help to user, it only does things more complicated. – wipet Apr 23 '15 at 7:41
  • I'm really liking these solutions. Have to agree that the plain tex is more simple, at least to a new comer like me. But since I have to do a bunch of tables, I can try a bunch of solutions! – JuanKman94 Apr 27 '15 at 4:42
6

As far as I know, there is no such package, but it can be achieved with basic setups, using \multicolumn and \cline macros.

\documentclass[twoside]{book}

\usepackage{booktabs}
\usepackage{array}

\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}

\usepackage{blindtext}
\begin{document}


\large
\begin{tabular}{|*{8}{L{1cm}|}}
\hline
& 114 & & 100 & & 92 & & 101  \tabularnewline
& & & & & & &   \tabularnewline
\cline{2-2} \cline{4-4} \cline{6-6} \cline{8-8} 
\multicolumn{2}{|l|}{} & \multicolumn{2}{l|}{} & \multicolumn{2}{l|}{} & \multicolumn{2}{l|}{}\tabularnewline 
\multicolumn{2}{|l|}{113} & \multicolumn{2}{l|}{99} & \multicolumn{2}{l|}{84} & \multicolumn{2}{l|}{97}  \tabularnewline
\hline
& 114 & & 100 & & 92 & & 101  \tabularnewline
& & & & & & &   \tabularnewline
\cline{2-2} \cline{4-4} \cline{6-6} \cline{8-8} 
\multicolumn{2}{|l|}{} & \multicolumn{2}{l|}{} & \multicolumn{2}{l|}{} & \multicolumn{2}{l|}{}\tabularnewline 
\multicolumn{2}{|l|}{113} & \multicolumn{2}{l|}{99} & \multicolumn{2}{l|}{84} & \multicolumn{2}{l|}{97}  \tabularnewline
\hline
& 114 & & 100 & & 92 & & 101  \tabularnewline
& & & & & & &   \tabularnewline
\cline{2-2} \cline{4-4} \cline{6-6} \cline{8-8} 
\multicolumn{2}{|l|}{} & \multicolumn{2}{l|}{} & \multicolumn{2}{l|}{} & \multicolumn{2}{l|}{}\tabularnewline 
\multicolumn{2}{|l|}{113} & \multicolumn{2}{l|}{99} & \multicolumn{2}{l|}{84} & \multicolumn{2}{l|}{97}  \tabularnewline
\hline
\end{tabular}

% Now with booktabs features 

\begin{tabular}{|*{8}{L{0.5cm}|}}
\toprule
& 114 & & 100 & & 92 & & 101  \tabularnewline
&  & &  & &  & &   \tabularnewline
\cmidrule{2-2} \cmidrule{4-4} \cmidrule{6-6} \cmidrule{8-8} 
\multicolumn{2}{|l|}{} & \multicolumn{2}{l|}{} & \multicolumn{2}{l|}{} & \multicolumn{2}{l|}{}\tabularnewline 
\multicolumn{2}{|l|}{113} & \multicolumn{2}{l|}{99} & \multicolumn{2}{l|}{84} & \multicolumn{2}{l|}{97}  \tabularnewline
\hline
& 114 & & 100 & & 92 & & 101  \tabularnewline
&  & &  & &  & &   \tabularnewline
\cmidrule{2-2} \cmidrule{4-4} \cmidrule{6-6} \cmidrule{8-8} 
\multicolumn{2}{|l|}{} & \multicolumn{2}{l|}{} & \multicolumn{2}{l|}{} & \multicolumn{2}{l|}{}\tabularnewline 
\multicolumn{2}{|l|}{113} & \multicolumn{2}{l|}{99} & \multicolumn{2}{l|}{84} & \multicolumn{2}{l|}{97}  \tabularnewline
\hline
& 114 & & 100 & & 92 & & 101  \tabularnewline
&  & &  & &  & &   \tabularnewline
\cmidrule{2-2} \cmidrule{4-4} \cmidrule{6-6} \cmidrule{8-8} 
\multicolumn{2}{|l|}{} & \multicolumn{2}{l|}{} & \multicolumn{2}{l|}{} & \multicolumn{2}{l|}{}\tabularnewline 
\multicolumn{2}{|l|}{113} & \multicolumn{2}{l|}{99} & \multicolumn{2}{l|}{84} & \multicolumn{2}{l|}{97}  \tabularnewline
\hline
\end{tabular}

\normalsize
\end{document}

enter image description here

|improve this answer|||||
  • The booktabs (lower one) version is better, in my point of view – user31729 Apr 22 '15 at 21:42
  • 1
    Why do you think the lower one is better? To me the above one is definitely better (at least the lines are together). – Manuel Apr 22 '15 at 21:46
  • @Manuel: A personal impression. It's quite difficult to tell – user31729 Apr 22 '15 at 21:57
5
\documentclass{scrartcl}
\usepackage{tikz}

\tikzset{/bowlinggrid/.cd,
  box width/.store in=\bgridlargewidth,box width=3cm,
  box height/.store in=\bgridlargeheight,box height=2.5cm,
  small width/.store in=\bgridsmallwidth,small width=1.2cm,
  small height/.store in=\bgridsmallheight,small height=1cm,
  columns/.store in=\bgridcolnumber,columns=4} % I cannot get /.initial= to work
\newcommand*\bowlinggrind[2][]
  {%
   \begin{tikzpicture}
   \tikzset{/bowlinggrid/.cd,#1}
   \foreach \N/\n [count=\cnt] in {#2}
     {
      \pgfmathsetmacro\currcolnumber{int(mod(\cnt-1,\bgridcolnumber))}
      \pgfmathsetmacro\currrownumber{int(ceil(\cnt/\bgridcolnumber))}
      \draw
       ({\currcolnumber*\bgridlargewidth},{-\currrownumber*\bgridlargeheight})
        node [above right] {\N}
        rectangle ++(\bgridlargewidth,\bgridlargeheight)
        rectangle ++(-\bgridsmallwidth,-\bgridsmallheight)
        node [above right] {\n};
     }
   \end{tikzpicture}%
  }

\begin{document}
\begin{center}
\bowlinggrind
  {113/114,99/100,84/92,97/101,
   113/114,99/100,84/92,97/101,
   113/114,99/100,84/92,97/101,
   113/114,99/100,84/92,97/101}
\end{center}
\begin{center}
\bowlinggrind[box width=1.8cm,box height=1.3cm,small width=.9cm,small height=.5cm]
  {113/114,99/100,84/92,97/101,
   113/114,99/100,84/92,97/101,
   113/114,99/100,84/92,97/101,
   113/114,99/100,84/92,97/101}
\end{center}
\end{document}

enter image description here

|improve this answer|||||
5

Paul Gessler wrote the Plain TeX solution using \halign. Great. I add another Plain TeX solution using only \hbox \vbox. The main idea is: if there are only fixed-size columns then we needn't to use \halign, but the \hbox to construction is sufficient.

\def\bx#1#2{\vbox{\hbox to4em{\hss\vbox{%
                      \hbox to2em{\strut\vrule\hfil#2\hfil}\hrule}}
                  \hbox to2em{\strut\hfil#1\hfil}}\vrule\ignorespaces
}
\def\bxx{\hbox{\vrule \bx{113}{114} \bx{99}{100} \bx{84}{92} \bx{97}{101} }%
         \hrule}

\vbox{\hrule \bxx \bxx \bxx}

\bye
|improve this answer|||||
5

FWIW, this effect is relatively easy to achieve in ConTeXt. Note the very clean separation of content and presentation.

\startsetups[cellular]
  \setupTABLE[frame=off, align={middle,lohi}, offset=0.5em]
  \setupTABLE[even] [odd][frame=on, offset=0.25em]
  \setupTABLE[even][even][rightframe=on, bottomframe=on]
  \setupTABLE[odd] [even][leftframe=on,  bottomframe=on]
  \setupTABLE[odd]  [odd][leftframe=on,  topframe=on]
\stopsetups

\starttext
\startTABLE[setups=cellular]
   \NC     \NC 114 \NC    \NC 100 \NC    \NC 92 \NC    \NC 101 \NC \NR
   \NC 113 \NC     \NC 99 \NC     \NC 84 \NC    \NC 97 \NC     \NC \NR
   \NC     \NC 114 \NC    \NC 100 \NC    \NC 92 \NC    \NC 101 \NC \NR
   \NC 113 \NC     \NC 99 \NC     \NC 84 \NC    \NC 97 \NC     \NC \NR
   \NC     \NC 114 \NC    \NC 100 \NC    \NC 92 \NC    \NC 101 \NC \NR
   \NC 113 \NC     \NC 99 \NC     \NC 84 \NC    \NC 97 \NC     \NC \NR
\stopTABLE
\stoptext

enter image description here

|improve this answer|||||
4

With standard LaTeX methods, also with a friendly syntax. The trick is to nest tabular environments.

\documentclass{article}

\newlength{\blockwidth}
\AtBeginDocument{\settowidth{\blockwidth}{0000}}

\newcommand{\block}[2]{%
  \begin{tabular}{@{}c|c@{}}
  & \makebox[\blockwidth][r]{#2\enspace} \\
  \cline{2-2}
  \multicolumn{1}{c}{\makebox[\blockwidth][r]{#1\enspace}}
  \end{tabular}%
}

\begin{document}

\begin{tabular}{|*{4}{@{}c@{}|}}
\hline
\block{113}{114} & \block{99}{100} & \block{84}{92} & \block{97}{101} \\
\hline
\block{113}{114} & \block{99}{100} & \block{84}{92} & \block{97}{101} \\
\hline
\block{113}{114} & \block{99}{100} & \block{84}{92} & \block{97}{101} \\
\hline
\end{tabular}

\end{document}

The shape of the blocks can be easily adapted if some more room is desired.

enter image description here

|improve this answer|||||
1

A free interpretation of the desired design that is not a table, so that allow a flexible format.

MWE

\documentclass[a5paper]{article}
\newcounter{cell}
\usepackage{xcolor}

\def\nestedcell#1{%
\noindent\fboxsep5pt\fboxrule1pt
\fbox{\begin{minipage}[b][2cm]{\dimexpr.25\textwidth-12pt}
\hfill{\color{red}\vrule\begin{minipage}{.3\textwidth}
\centering\small\sffamily\arabic{cell}
\addtocounter{cell}{1}
\par\smallskip\hrule\end{minipage}}\par\vfill
\raggedright#1\vphantom{hp}\end{minipage}}\hspace{1.25pt}}

\def\nocell#1{%
\noindent\fboxsep6pt\fboxrule0pt
\fbox{\begin{minipage}[b][2cm]{\dimexpr.25\textwidth-12pt}
\par\vfill
\raggedright#1\mbox{\vphantom{hp}}\end{minipage}}\hspace{1.25pt}}


\begin{document}
\nestedcell{101}% 
\nestedcell{}% cell with no content
\nestedcell{103}%
\nestedcell{104}%
\nestedcell{105}%
\nestedcell{106}%
\nocell{}%
\nestedcell{106}%
\nestedcell{107}\nestedcell{Some too long for a row}%
\nestedcell{108}\nestedcell{109}%
\nocell{I am still here}%
\nocell{}%
\nestedcell{}%
\nestedcell{Do not use more text than this.}%
\end{document}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.