1

I am trying to put the text on the same baseline. The text under picture A is a little bit higher than the text under picture B although both are centered. I think it is because of letters like g, p and in this case the letter y. The text baseline of picture A should be one the same baseline like the text under picture B (a little bit lower) so both texts have the same height. How can I accomplish that? Is there any way to set the text baseline of Bremssystem on the same baseline as Abstandsassistent without changing anything else?

Here is my MWE:

\documentclass[tikz]{standalone}
\usepackage{mwe}

\usetikzlibrary{shapes, arrows.meta, positioning, calc}
\tikzset{every picture/.style={/utils/exec={\sffamily\small}}}

\newlength\Textwd
\setlength\Textwd{3cm}
\newcommand\Textbox[2]{%
    \parbox[c][#1][c]{\Textwd}{\centering#2}}

\tikzstyle{textboxSplit} = [rectangle split, rectangle split parts = 2,
rectangle split part align = {center, minimum size = 2cm}, minimum width = 3cm, rounded corners = 1pt, line width = 1pt, draw = black, text centered]

\begin{document}
    \begin{tikzpicture}[outer sep = 0, inner sep = 0pt]

        \node [textboxSplit, rectangle split part fill = {white, white}] (textbox1) {\nodepart{one} \Textbox{1.5cm} {\includegraphics[width = 2.5cm, height = 1.25cm]{example-image-a}} \nodepart{two}   
        \Textbox{0.5cm} {Bremssystem}};
        
        \node [textboxSplit, right = 0cm of textbox1, rectangle split part fill = {white, yellow}] (textbox3) {\nodepart{one} \Textbox{1.5cm} {\includegraphics[width = 2.5cm, height = 1.25cm]{example-image-b}} \nodepart{two} \Textbox{0.5cm} {Abstandsassistent}};
        
    \end{tikzpicture}
\end{document}
4

EDIT: A DIRTY TRICK

Getting rid of the Textboxes and adding a \vphantom to the \strut made it a little better. Hope it suits your needs.

V2

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{mwe}

\usetikzlibrary{shapes, arrows.meta, positioning, calc}
\tikzset{every picture/.style={/utils/exec={\sffamily\small}}}

\newlength\Textwd
\setlength\Textwd{3cm}
\newcommand\Textbox[2]{%
    \parbox[c][#1][c]{\Textwd}{\centering#2}}

\tikzstyle{textboxSplit} = [rectangle split,inner ysep=0pt,rectangle split parts = 2,
rectangle split part align = {center, minimum size = 2cm}, minimum width = 3cm, rounded corners = 1pt, line width = 1pt, draw = black, text centered]

\begin{document}
    \begin{tikzpicture}[outer sep = 0, inner sep = 0pt]

        \node [textboxSplit,rectangle split part fill = {white, white}] (textbox1) {\nodepart{one} \Textbox{1.5cm} {\includegraphics[width = 2.5cm, height = 1.25cm]{example-image-a}} \nodepart{two}   
        {\strut \vphantom{\big(}Bremssystem}};
        
        \node [textboxSplit, right = 0cm of textbox1, rectangle split part fill = {white, yellow}] (textbox3) {\nodepart{one} \Textbox{1.5cm} {\includegraphics[width = 2.5cm, height = 1.25cm]{example-image-b}} \nodepart{two} {\strut \vphantom{\big(} Abstandsassistent}};
        
    \end{tikzpicture}
\end{document}

ORIGINAL VERSION (not satisfying)

Just add \strut to your text, (edit) and rise the inner ysep a bit.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{mwe}

\usetikzlibrary{shapes, arrows.meta, positioning, calc}
\tikzset{every picture/.style={/utils/exec={\sffamily\small}}}

\newlength\Textwd
\setlength\Textwd{3cm}
\newcommand\Textbox[2]{%
    \parbox[c][#1][c]{\Textwd}{\centering#2}}

\tikzstyle{textboxSplit} = [rectangle split, inner ysep=3pt,rectangle split parts = 2,
rectangle split part align = {center, minimum size = 2cm}, minimum width = 3cm, rounded corners = 1pt, line width = 1pt, draw = black, text centered]

\begin{document}
    \begin{tikzpicture}[outer sep = 0, inner sep = 0pt]

        \node [textboxSplit,rectangle split part fill = {white, white}] (textbox1) {\nodepart{one} \Textbox{1.5cm} {\includegraphics[width = 2.5cm, height = 1.25cm]{example-image-a}} \nodepart{two}   
        \Textbox{0.5cm} {\strut Bremssystem}};
        
        \node [textboxSplit, right = 0cm of textbox1, rectangle split part fill = {white, yellow}] (textbox3) {\nodepart{one} \Textbox{1.5cm} {\includegraphics[width = 2.5cm, height = 1.25cm]{example-image-b}} \nodepart{two} \Textbox{0.5cm} {\strut Abstandsassistent}};
        
    \end{tikzpicture}
\end{document}

baseline in rectangle split

6
  • I want Bremssystem lower and not Abstandsassistent higher! Otherwise it is not in the center anymore. so \strut seems to be the wrong way
    – Bolle
    Jul 25 '21 at 21:08
  • Actually, the word Bramssystem is vertically aligned (but seems too high, because of the y). You can play with the inner ysep to arrange that a bit. I'll edit my answer.
    – SebGlav
    Jul 25 '21 at 22:03
  • thanks, I think the answer is good but now the box gets bigger and that is something I really don't want. There must be a way the box keeps the height and sets the text baseline of Bremssystem on the same baseline as Abstandsassistent without changing anything else.
    – Bolle
    Jul 26 '21 at 6:20
  • You're right, but in fact, \strut place both words on the same baseline (which is the line underneath the e, for example), so they are. Unfortunately, in lowercase Bremssystem, the y has a descender, causing a different depth, which add the same depth but filled with white on the other word, which has no descender. rectangle split is a very tickly command, not that customizable, but there must be a way with a \phantom.
    – SebGlav
    Jul 26 '21 at 8:15
  • 1
    thank you for your solution! is there a chance to still define the height of the textbox? Otherwise I found a working solution. You can use a raisebox with a negative value like \raisebox{-8pt}{Bremssystem}. It is also a bit dirty but it works!
    – Bolle
    Jul 26 '21 at 9:46
2

A small variation o original answer of @SebGlaw. By defining own strut, for example \def\mystrut{\rule[-0.45ex]{0pt}{1.05em}} seem that OP request is fulfilled by less complex image code:

enter image description here

Edit: Added is border to standalone:

\documentclass[border=3.141592]{standalone} % <---
\usepackage{mwe}
\usepackage{tikz}
\usetikzlibrary{positioning, 
                shapes.multipart}

\begin{document}
    \begin{tikzpicture}[
      node distance = 0pt,
textboxSplit/.style = {rectangle split, 
                       rectangle split parts=2,
                       draw, line width=1pt, rounded corners=1pt,
                       text width=25mm,  align=center,
                       inner sep=2pt, outer sep=0,
                       font=\sffamily\small}
                        ]   
\setkeys{Gin}{width = \linewidth, height = 1.25cm}
\def\mystrut{\rule[-0.45ex]{0pt}{1.05em}}
\node [textboxSplit] (textbox1) 
    {\nodepart{one} \includegraphics{example-image-a} 
     \nodepart{two} Bremssystem\mystrut};
\node [textboxSplit, rectangle split part fill={white,yellow},
       right = 0cm of textbox1, ] (textbox3) 
    {\nodepart{one} \includegraphics{example-image-b} 
     \nodepart{two}  Abstandsassistent\mystrut};
    \end{tikzpicture}
\end{document}
3
  • Hi Zarko, in your screenshot there is a strange rectangle into the rounded boxes. It is coloured with the light gray. What is it?
    – Sebastiano
    Jul 26 '21 at 12:27
  • 1
    Hi @Sebastiano, this seems to be screen background. I didn't add some border to standalone image so at cutting it from screen is now visible pdf background. I will correct this ASAP.
    – Zarko
    Jul 26 '21 at 12:41
  • Don't worry :-) just it was a trivial advice :-)
    – Sebastiano
    Jul 26 '21 at 14:46
1

Thanks to the help of SebGlav I found an answer. For anyone who is interested and has the same kind of question how to set the text baseline of Bremssystem on the same baseline as Abstandsassistent without changing anything else like box height etc. in a rectangle split you just have to use a raisebox before the text you want to change the positioning of the height .

\documentclass[tikz]{standalone}
\usepackage{mwe}

\usetikzlibrary{shapes, arrows.meta, positioning, calc}
\tikzset{every picture/.style={/utils/exec={\sffamily\small}}}

\newlength\Textwd
\setlength\Textwd{3cm}
\newcommand\Textbox[2]{%
    \parbox[c][#1][c]{\Textwd}{\centering#2}}

\tikzstyle{textboxSplit} = [rectangle split, rectangle split parts = 2,
rectangle split part align = {center, minimum size = 2cm}, minimum width = 3cm, rounded corners = 1pt, line width = 1pt, draw = black, text centered]

\begin{document}
    \begin{tikzpicture}[outer sep = 0, inner sep = 0pt]

        \node [textboxSplit, rectangle split part fill = {white, white}] (textbox1) {\nodepart{one} \Textbox{1.5cm} {\includegraphics[width = 2.5cm, height = 1.25cm]{example-image-a}} \nodepart{two}   
        \Textbox{0.5cm} {\raisebox{-8pt}{Bremssystem}}};
        
        \node [textboxSplit, right = 0cm of textbox1, rectangle split part fill = {white, yellow}] (textbox3) {\nodepart{one} \Textbox{1.5cm} {\includegraphics[width = 2.5cm, height = 1.25cm]{example-image-b}} \nodepart{two} \Textbox{0.5cm} {Abstandsassistent}};
        
    \end{tikzpicture}
\end{document}
0

A similar structre made with a tcbraster from tcolorbox package. In this case adjusted title option allows to automatically fix equal size for titles.

\documentclass{article}
\usepackage[most]{tcolorbox}
\begin{document}
\begin{tcbraster}[raster columns=2, raster equal height, raster column skip=-1pt, 
    colback=white, colframe=black, fonttitle=\sffamily\small, 
    colbacktitle=white, coltitle=black, halign title=center, 
    arc=1pt, flip title, raster width center=7cm]
\tcbincludegraphics[adjusted title=Bremssystem]{example-image-a}
\tcbincludegraphics[adjusted title=Abstandsassistent, colbacktitle=yellow]{example-image-b}
\end{tcbraster}
\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.