3
 \newcommand*\round[2]{%
\tikz[baseline=(char.base)]
\node[anchor=north west, draw,rectangle ,rounded corners, inner xsep=5.6cm,
 minimum size=5.5mm, height=3.6mm, fill=#2,#2,text=white,align= left](char){#1};
%
}

I am getting this, but I need the text to be left aligned and the round boxes to be the same size.

  • 1
    Welcome to TeX-SE! Are you aware of the tcolorbox package? – user121799 May 27 at 1:54
1

I have changed some of your parameters and condensed them to what you need. Keep in mind that text width is what you needed (you don't have to use align = left because it is set to left by default).

enter image description here

\documentclass{article}
\usepackage{tikz}
\newcommand\round[2]{\par
    \noindent\begin{tikzpicture}%
        \node[draw = #1, fill = #1, rectangle, rounded corners, 
              minimum size = 5.5mm, text = white, text width = 10cm](char){#2};
    \end{tikzpicture}\par%
}%
\begin{document}
    \round{blue}{First Title}
    some text\\
    \round{red}{Second Title}
    some text\\
\end{document}
0

Welcome to TeX-SE! I think the following addresses your requirements:

\documentclass{article}
\usepackage{tikz}
\newcommand*\round[2][blue]{%
\tikz[baseline=(char.base)]\node[shape=rectangle,
rounded corners, minimum width=\textwidth,text width=\textwidth-3em, 
minimum  height=2em,text depth=0.3em,
 fill=#1,text=white,align=left,font=\sffamily](char){#2};%
}
\begin{document}
\noindent
\round{Some text}

\noindent
\round[blue!70!black]{Some other text}

\end{document}

enter image description here

However, I feel you might be better off using tcolorbox, which is based on tikz. Using this answer you may do

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

\newtcolorbox{rounded}[1][]{enhanced jigsaw,colback=blue,
boxrule=0pt,arc=2mm,auto outer arc,boxsep=0pt,coltext={white},fontupper=\sffamily,
#1}

\begin{document}

\begin{rounded}
Some text
\end{rounded}

\begin{rounded}[colback=blue!70!black]
Some more text
\end{rounded}
\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.