0

i need two separate tables using matrix in tikzpicture. With my code i do not get proper alignment and even from one row to another. I tried increasing the "minimum height" and "row sep={xxem, between origins}" but none helped. I basically work with both devanagari text and latin. Though this alignment problem does not seem to depend on font, i left both in my mwe.

\documentclass[a4paper]{article}

\usepackage[verbose,vmargin=30mm,hmargin=20mm]{geometry}

\usepackage{tikz}
\usetikzlibrary{positioning, matrix}
\usepackage{babel}

\babelprovide[mapdigits,maparabic,import,main]{sanskrit}
\babelprovide[onchar=ids fonts]{english}
%rm : serif -- sf : sans -- tt : mono

\babelfont[*devanagari]{sf}{Shobhika}
\babelfont[*devanagari]{rm}[Language=Default]{NotoSerifDevanagari}
\babelfont[english]{sf}{FreeSans}
\babelfont[english]{rm}{NotoSerif}
\defaultfontfeatures{Renderer=Harfbuzz}

\tikzset{
  texttable/.style={row sep={.8em}, column sep=-\pgflinewidth,
         nodes={anchor=center, font=\Large, minimum height=4em, 
         text width=#1, inner sep=5pt,outer sep=0pt, draw},
}}
\begin{document}
    \noindent
\begin{tikzpicture}

    \matrix at (0,0) [matrix of nodes, nodes in empty cells, draw,
    texttable={2cm}, align=right] (tb1)
    {
    पुत्रः माता। & माता। \\
    putraḥ \\
    शिष्यः। \\
    śiṣyaḥ \\};

    \matrix at (tb1.north east) [matrix of nodes, nodes in empty cells, draw,
    texttable={2cm}, align=left, matrix anchor=north west, xshift=5mm] (tb2)
    {
    माता। \\
    mātā \\
    गुरुः। \\
    guruḥ \\};
\end{tikzpicture}
\end{document}

1 Answer 1

1

the options text depth and text height must be used here.

\documentclass[a4paper]{article}

\usepackage[vmargin=30mm,hmargin=20mm]{geometry}

\usepackage{tikz}
\usetikzlibrary{matrix,calc}
\usepackage{babel}

\babelprovide[mapdigits,maparabic,import,main]{sanskrit}
\babelprovide[onchar=ids fonts]{english}
%rm : serif -- sf : sans -- tt : mono

\babelfont[*devanagari]{sf}{Shobhika}
%\babelfont{sf}{}
\babelfont[*devanagari]{rm}[Language=Default]{NotoSerifDevanagari}
\babelfont[english]{sf}{FreeSans}
\babelfont[english]{rm}{NotoSerif}
\defaultfontfeatures{Renderer=Harfbuzz}

\tikzset{
  texttable/.style={row sep=-\pgflinewidth, column sep=-\pgflinewidth,
         nodes={anchor=center,outer sep=0pt,draw,
         text width=#1,text depth=0.5ex,text height=12pt, font=\large,nodes={}}},
  ttold/.style={row sep=-\pgflinewidth, column sep=-\pgflinewidth,
         nodes={anchor=center, text width=#1,
         outer sep=0pt,draw,minimum height=2em, font=\large,}}}

\setlength{\parindent}{0pt}

\begin{document}
\begin{tikzpicture}
    \node at (0,0) [font=\Large,anchor=west] (title1) {Previous version:};
    \draw [ultra thick, yshift=-1mm] (title1.south west) -- (title1.south east);

    \matrix at (0,-7mm) [matrix of nodes, nodes in empty cells,
    matrix anchor=north west,
    ttold={2cm}, align=right] (tbold)
    {
    \node (a) {पुत्रः माता।}; & माता।\\
    \node (b) {putraḥ}; & mātā\\
    शिष्यः। & गुरुः\\
    śiṣyaḥ & guruḥ\\
    };
    \draw [thick,red] ($(a.south west)+(6mm,2mm)$) -- ++(60mm,0);
    \draw [thick,red] ($(b.south west)+(6mm,2mm)$) -- ++(60mm,0);

    \matrix at (tbold.north east) [matrix of nodes, nodes in empty cells,
    matrix anchor=north west,
    ttold={2cm}, align=right] (tb2)
    {
    माता। \\
    mātā \\
    गुरुः। \\
    guruḥ \\};

    \node at (.5\textwidth,0) [font=\Large,anchor=west] (title2) {New version:};
    \draw [ultra thick, yshift=-1mm] (title2.south west) -- (title2.south east);

    \matrix at (.5\textwidth,-7mm) [matrix of nodes, nodes in empty cells,
    matrix anchor=north west,
    texttable={2cm}, align=right] (tbnew)
    {
    \node (c) {पुत्रः माता।}; & माता।\\
    \node (d) {putraḥ}; & mātā\\
    शिष्यः। & गुरुः\\
    śiṣyaḥ & guruḥ\\
    };
    \draw [thick,red] ($(c.south west)+(6mm,2mm)$) -- ++(60mm,0);
    \draw [thick,red] ($(d.south west)+(6mm,2mm)$) -- ++(60mm,0);

    \matrix at (tbnew.north east) [matrix of nodes, nodes in empty cells,
    matrix anchor=north west,
    texttable={2cm}, align=right] (tb3)
    {
    माता।\\
    mātā\\
    गुरुः। \\
    guruḥ \\};
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .