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.

3
  • 1
    Perhaps a duplicate of this: tex.stackexchange.com/questions/133227/…, 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};} Apr 5, 2022 at 1:13
  • 1
    @StevenB.Segletes Using a strut made it work perfectly, thank you!
    – xanderr
    Apr 5, 2022 at 1:22
  • This should probably be an answer …
    – Ingmar
    Apr 5, 2022 at 6:48

1 Answer 1

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

You must log in to answer this question.

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