2

Here is the MWE:

\documentclass{article}

\usepackage{tikz}

\newcommand{\rbox}[1]{
  \begin{tikzpicture}[remember picture, overlay]
    \node[rounded corners=3pt, draw]{#1};                                                                                             
  \end{tikzpicture}
}

\begin{document}

  \begin{itemize}
    \item \rbox{Hello World in rounded corner box} Hello World
    \item Hello
    \item World
  \end{itemize}

\end{document}

I was expecting 'Hello World in rounded corner box' perfectly aligned with the corresponding bullet point. In reality, 'Hello World in ronded corner box' is placed such that the bullet appears in it. Moreover, the baseline alignment is not correct.

What do I need to do to get this right?

2

Using baseline option in tikz was the solution.

Here is the MWE that produces the desired result:

\documentclass{article}

\usepackage{tikz}

\newcommand{\rbox}[1]{
  \begin{tikzpicture}[baseline]
    \node[rounded corners=3pt, draw, anchor=base]{#1};                                                                                
  \end{tikzpicture}
}

\begin{document}

  \begin{itemize}
    \item \rbox{HelloWorld} Hello World
    \item Hello
    \item World
  \end{itemize}

\end{document}

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.