3

I basically have the exact same problem as this question, only for multi-part nodes: I have a node that consists of 3 parts, each of which contains text. I want to have the text aligned by its baseline. I tried to achive this using the text height and text depth, which works fine for ordinary nodes, but not for multi-part ones. As you can see in the image below, only the first part of the node receives the correct alignment I want to achieve, the other two get "push up" by characters that extend below the baseline.

The Problem

This is my latex-code:

\documentclass[tikz, 11pt,landscape]{article}

\usepackage[default,osfigures,scale=0.95]{opensans}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{tgbonum}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}

\usepackage[a3paper]{geometry}

\begin{document}
\thispagestyle{empty}

\tikzset{normal/.style = {rectangle split, rectangle split horizontal, rectangle split parts=3, very thick, draw=black, minimum height=0.6cm,text height=1.5ex, text depth=0.25ex}}

\begin{tikzpicture}[remember picture, overlay]
    \node[normal] at (current page.center) {\nodepart{one} ag \nodepart{two} ag \nodepart{three} ag};
\end{tikzpicture}    
\end{document}

I found another post about someone having the same problem with transparency only beeing applied to the first part, but its solution didn't work for me. I do not care about multi-line text and actually only really care about the alignment in the second part of the node, I just included the other two texts for demonstration. It seems like whatever I try, it only gets applied to the first part.

Edit:

Using my screenshot as an example: I want the 2nd and 3rd box to be aligned to the height of the 1st one. I do NOT want to align the 1st box to the height of the 2nd and 3rd one, since that is quite high and looks strange if I have a text without characters that go below the baseline. The spacing will look very uneven.

pulp_user
  • 147

1 Answers1

2

A lot of thanks to @CarlaTex kindness and to her explanations that make me understand ( I hope this time I am not wrong!) what is really needed by this question

The workaround is the use of an invisible \rule that has the correct vertical dimensions (height and depth):

\documentclass[tikz, 11pt,landscape]{article}

\usepackage[default,osfigures,scale=0.95]{opensans}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{tgbonum}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}

\usepackage[a3paper]{geometry}

\begin{document}
\thispagestyle{empty}

\tikzset{
    normal/.style = {
       rectangle split, 
       rectangle split horizontal, 
       rectangle split parts=3, 
       very thick, draw=black, 
       minimum height=2cm,
       text height=1.5cm, 
       text depth=0.25cm
                    }
        }

\begin{tikzpicture}[remember picture, overlay]
    \node[normal] at (current page.center) {\nodepart{one} ag 
            \nodepart{two} \rule[-0.25cm]{0pt}{1.75cm}ag 
             \nodepart{three} \rule[-0.25cm]{0pt}{1.75cm}ag};
\end{tikzpicture}    
\end{document}

enter image description here

  • @CarLaTeX The three node parts are aligned. What doesn't work ? – Hafid Boukhoulda Feb 18 '19 at 19:50
  • @CarLaTeX I confess that I don't understand what is needed. – Hafid Boukhoulda Feb 18 '19 at 20:11
  • @CarLaTeX If I move minimum height=0.6cm in the normal style I get the image posted in the OP. The three parts contents being not vertically aligned and I still don't understand what is needed. – Hafid Boukhoulda Feb 18 '19 at 20:20
  • I tried this solution, and you are right, they are vertically aligned. However: They all get "pushed up" now. If I insert text without a character that goes below the baseline, it looks strange. What I wanted was to align the height of the 2nd and 3rd box to the height of the 1st. Your solution aligns the 1st box to the height of the 2nd and 3rd. I hope that makes sense. I edited the question to better clarify that. – pulp_user Feb 18 '19 at 21:04
  • @pulp_user answer updated ! Is that what is needed ? – Hafid Boukhoulda Feb 18 '19 at 21:31
  • Yes! Thank you very much. It is a bit dirty (for example I think the node-border is as big as if the letters were still up high) but it definitely works. – pulp_user Feb 18 '19 at 22:06
  • @pulp_user I have used big values for the text height and depth to better show the problem and the solution – Hafid Boukhoulda Feb 18 '19 at 22:18
  • oh ok. I thought it was a mistake since with ex it fits perfectly. nevermind. – pulp_user Feb 18 '19 at 22:21