1
0   1   2   3
R   R   R   R
*¯¯¯*¯¯¯*¯¯¯*
* a | b | c |
*___*___*___*
L   L   L   L

I would like to create a grid similar to the one above, it would be a grid with a single letter per cell and at each cell divider it would have R on the top and L on the bottom, and in addition to this numbers, starting at 0, at each cell divider; as shown above.

The * and ¯¯ characters are just for illustration purposes, and I would prefer an actual grid pattern.

  • Welcome to TeX SX! What exactly do you call a cell divider? – Bernard Jan 1 '16 at 15:09
  • So you want the R on top of the vertical lines? Not sure if that's possible with a regular tabular. – Alenanno Jan 1 '16 at 15:29
2

Without a bit more information about what the formatting is about, here's something slightly less than a brute force approach:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}

   \matrix [column sep=0pt,every node/.style={draw,inner sep=1.5ex,text depth=0.5ex,text height=1.5ex,anchor=base}]
   {
     \node(m0) {a}; & \node(m1) {b}; & \node(m2) {c}; \\
   };

  \foreach \myletter [count=\x from=0] in {0,1,2,3}
  {
    \ifnum\x<3\relax
      \node[anchor=south] (R\x)  at (m\x.north west) {R};
      \node[anchor=north] (L\x)  at (m\x.south west) {L};
    \else
      \node[anchor=south] (R\x)  at (m2.north east) {R};
      \node[anchor=north] (L\x)  at (m2.south east) {L};
    \fi
    \node[anchor=south]   at (R\x.north) {\x};
  }

\end{tikzpicture}

\end{document}

enter image description here

  • Thanks, that's what I was looking for. Any way to increase the size of the letters within the cells? – Khalid Jan 1 '16 at 18:37
  • @Khalid Inside of every node style, add font= and then add something among: \large, \Large, \LARGE, etc. – Alenanno Jan 3 '16 at 22:45
0

This is a simple solution with the blkarray package: I use the fact that different blocks, within a blockarray environment, can have different column separators:

\documentclass{article}

\usepackage{blkarray}
\usepackage{geometry}
\newcounter{col}
\usepackage{xcolor}
\usepackage{stackengine}
\setstackEOL{\\}
\usepackage{pst-node}
\usepackage{auto-pst-pdf}
\usepackage{dashrule}
\newcommand\dashfill{\leavevmode\cleaders\hbox{\rule{2.5pt}{0.3pt}\hskip2pt}\hfill\kern0pt}
\newcommand\vardashfill{\leavevmode\cleaders\hbox{\rule[0.25ex]{2.5pt}{0.3pt}\hskip2pt}\hfill\kern0pt}
\begin{document}


\centering
\setcounter{col}{0}
\begin{blockarray}{*{3}{c}}
  \begin{block}{@{\makebox[0pt]{\thecol}\stepcounter{col}}*{3}{c@{\makebox[0pt]{\thecol}\stepcounter{col}}}}
    & & \\
  \end{block}
  \begin{block}{@{\makebox[0pt]{R}}*{3}{c@{\makebox[0pt]{R}}}}
    & & \\[-1.5ex]
  \end{block}
  \begin{block}{@{\makebox[0pt]{\tiny\textbullet}}*{3}{>{\vardashfill}c@{\makebox[0pt]{\tiny\textbullet}}}}
    & & \\[-0.5ex]
  \end{block}
  \begin{block}{@{\hskip\tabcolsep}*{3}{>{\Large}c|}}
    a & b & c \\[-1.2ex]
  \end{block}
  \begin{block}{@{\makebox[0pt]{\tiny\textbullet}}*{3}{ >{\vardashfill}c@{\makebox[0pt]{\tiny\textbullet}}}}
    & & \\[-0.5ex]
  \end{block}
  \begin{block}{@{\makebox[0pt]{L}}*{3}{c@{\makebox[0pt]{L}}}}
    & & \\
  \end{block}
\end{blockarray}

\end{document} 

enter image description here

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.