1

I have a few rectangles that hold text made in Tikz next to eachother, and I want them to all be properly aligned vertically. The issue is that for boxes that hold words with letters such as j and y, the bottom of the box is extended and so the boxes with words that don't contain those letters are slightly higher, like so: enter image description here

Word and Box are higher than the other three, I would like them to all be at the same height. The command I am using to generate this is

\newcommand{\autour}[1]{\tikz[baseline=(X.base)]\node [fill=seafoam,rectangle,inner sep=5pt, anchor=text, rounded corners=5pt, minimum height=0.7cm] (X) {#1};}

\autour{\textcolor{white}{\textbf{June}}}

Any help is appreciated.

xanderr
  • 11
  • 1
    Perhaps a duplicate of this: https://tex.stackexchange.com/questions/133227/how-to-align-text-in-tikz-nodes-by-baseline, in which \strut may be used, as in \newcommand{\autour}[1]{\tikz[baseline=(X.base)]\node [fill=magenta,rectangle,inner sep=5pt, anchor=text, rounded corners=5pt, minimum height=0.7cm] (X) {\strut#1};} – Steven B. Segletes Apr 05 '22 at 01:13
  • 1
    @StevenB.Segletes Using a strut made it work perfectly, thank you! – xanderr Apr 05 '22 at 01:22
  • This should probably be an answer … – Ingmar Apr 05 '22 at 06:48

1 Answers1

1

An alternative construction with tcolorbox. It uses \strut solution as proposed by Steven B. Segletes.

\documentclass{article}
\usepackage[most]{tcolorbox}

\newtcbox{\autor}[1][]{% on line, size=fbox, arc=2mm, colback=violet, colupper=white, colframe=violet, before upper={\strut} }

\begin{document} This a list: \autor{June} \autor{Objective} \autor{Rhythm} \autor{Word} \autor{Box} \end{document}

enter image description here

Ignasi
  • 136,588