4

I'm reproducing an old textbook but I can't manage to typeset the tables. The column headings, or the title of the table, should be placed on the border itself.

Here are a two examples:

example1

example2

The first one corresponds to the following code:

\documentclass{standalone}

\begin{document}
  \fbox{
    \begin{tabular}{llll|lll}
      & & SINGULIER & & & PLURIEL \\
      & & & & & \\
      & MASCULIN & FÉMININ & NEUTRE & MASCULIN & FÉMININ & NEUTRE \\
      \textsc{Nom.} & \emph{is} & \emph{ea} & \emph{id} & \emph{ei} ou \emph{ii} & \emph{eæ} & \emph{ea}
    \end{tabular}
  }
\end{document}

I have neither included the accents nor the following lines as they are unrelated to the question.

4
  • Could you post what you tried, that we don't have to retype everything? Do you really want to type a Latin grammar?
    – Bernard
    Nov 29, 2020 at 13:56
  • Sure, but you can use dummy text if needed
    – user227615
    Nov 29, 2020 at 13:57
  • Yes, it's an old Latin grammar book of about a hundred pages, why?
    – user227615
    Nov 29, 2020 at 13:57
  • 2
    Just out of curiosity.
    – Bernard
    Nov 29, 2020 at 13:59

2 Answers 2

4
  • Typeset the table normally, including the headers.
  • Add \tikznode commands for each header 'on the line'.
  • Wrap the whole tabular into a \tikznode command.
  • Add a tikzpicture to draw the lines.

The \tikznode command is defined and described in this answer to "How to add arrow in equations and matrix".

For fine-tuning, use the optional argument of \tikznode to supply options to tikz. E.g., for adding more space around the tabular and the headers, you can define two styles by

\tikzset{tab/.style={inner sep=2pt},hdr/.style={inner xsep=4pt}}

and add tab and hdr as options to the \tikznode commands.

enter image description here

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\newcommand\tikznode[3][]{%
  \tikz[remember picture,baseline=(#2.base)]
    \node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
}
\tikzset{tab/.style={inner sep=2pt},hdr/.style={inner xsep=4pt}}
\begin{document}
\tikznode[tab]{singplu}{%
  \begin{tabular}{llll|lll}
    \multicolumn{4}{c}{\tikznode[hdr]{sing}{SINGULIER}} &  \multicolumn{3}{c}{\tikznode[hdr]{plu}{PLURIEL}} \\
    & & & & & \\
    & MASCULIN & FÉMININ & NEUTRE & MASCULIN & FÉMININ & NEUTRE \\
    \textsc{Nom.} & \emph{is} & \emph{ea} & \emph{id} & \emph{ei} ou \emph{ii} & \emph{eæ} & \emph{ea}
  \end{tabular}%
}%
\begin{tikzpicture}[remember picture,overlay]
  \draw (singplu.south west) |- (sing);
  \draw (sing) -- (plu);
  \draw (plu) -| (singplu.south east);
  \draw (singplu.south east) -- (singplu.south west);
\end{tikzpicture}

\end{document}
2
  • I will consider trying to automate the process but I accepted the solution, thank you
    – user227615
    Nov 29, 2020 at 15:00
  • I may regret having made this comment later, but I do not think that it is a good idea to nest tikzpictures. Note also that the tikzmark library defines a \tikzmarknode command. Finally, while I did not try I'd think that nicematrix could be a better choice.
    – user229669
    Nov 29, 2020 at 15:21
3

Here is a solution with {NiceTabular} of nicematrix.

\documentclass{article}
\usepackage[french]{babel}
\usepackage{lmodern}
\usepackage{nicematrix}
\usepackage{tikz}

\begin{document}

\newcolumntype{:}{!{\vrule}}

\begin{NiceTabular}{|llll:lll|}
\Hline
\noalign{\vspace{4mm}}
  & MASCULIN & FÉMININ & NEUTRE & MASCULIN & FÉMININ & NEUTRE \\
  \textsc{Nom.} & \emph{is} & \emph{ea} & \emph{id} & \emph{ei} ou \emph{ii} & \emph{eæ} & \emph{ea} \\
\noalign{\vspace{1mm}}
\Hline
\CodeAfter
\tikz \draw (1-|1) -- node [fill=white] {SINGULIER} (1-|5) 
            (1-|5) -- node [fill=white] {PLURIEL} (1-|8) ;
\end{NiceTabular}%

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes).

Output of the above code

You must log in to answer this question.