4

I'm trying to draw a callout that has a nice big i on the left side, and then a bunch of text filling most of the body. The following code almost works:

\documentclass[a4paper,oneside]{article}

\usepackage{xcolor}
\definecolor{Info}{rgb}{0.9,0.5,0.0}
\usepackage{tikz}
\usepackage{anyfontsize}
\usepackage{environ}
\NewEnviron{Note}%
{
  \begin{center}
    \begin{tikzpicture}
      \node[rectangle, rounded corners=15pt, inner sep=15pt, fill=Info](box){%
        \begin{minipage}{0.9\textwidth}
          \color{white}
          \mbox{\fontsize{40}{40}\selectfont$i$}
          \hfill
          \begin{minipage}{0.95\textwidth}
            \bfseries\BODY
          \end{minipage}
        \end{minipage}};
    \end{tikzpicture}
  \end{center}
}

\begin{document}
\begin{Note}
  This is a test. This is a test.
  This is a test. This is a test.
  This is a test. This is a test.
  This is a test. This is a test.
  This is a test.
\end{Note}
\end{document}

But it renders like this:

Example image

I'm not sure what TeX is actually aligning that against. What's going on?

If anything, the position of the i actually looks OK; it's the body text that seems to somehow be in the wrong place. I can't figure out what's moving it.

So how do I fix this? I'll accept having the i fixed to the top or having it vertically centered, just so long as the body text ends up in the right place.

4

You have one big minipage and inside which you have put the large i (without minipage) and the body text inside another minipage. Now due to how much body text you put, the height of the inner minipage varies. Since you have not specified the vertical alignment for inner mini page, the default center is applied for example,in the following figure, center of mini page is aligned with the center of x.

enter image description here

So you get different looks with different amount of text (height) as always the center is aligned.

As a remedyut the i and the body text in separate minipages and you won't need the outer minipage.

\documentclass[a4paper,oneside]{article}

\usepackage{xcolor}
\definecolor{Info}{rgb}{0.9,0.5,0.0}
\usepackage{tikz}
\usepackage{anyfontsize}
\usepackage{environ}
\NewEnviron{Note}%
{
  \begin{center}
    \begin{tikzpicture}
      \node[rectangle, rounded corners=15pt, inner sep=15pt, fill=Info](box){%
        \begin{minipage}{0.05\textwidth}
          \color{white}
          \mbox{\fontsize{40}{48}\selectfont$i$}
        \end{minipage}
          \hfill
          \begin{minipage}{0.9\textwidth}
            \bfseries\BODY
          \end{minipage}
};
    \end{tikzpicture}
  \end{center}
}

\begin{document}
\begin{Note}
  This is a test. This is a test.
  This is a test. This is a test.
  This is a test. This is a test.
  This is a test. This is a test.
  This is a test.
\end{Note}
\end{document}

enter image description here

Here is a tcolorbox solution. Why tcolorbox? You can do lot of beautification with this. For details, refer to its manual.

\documentclass[a4paper,oneside]{article}
\usepackage{anyfontsize}
\usepackage[many]{tcolorbox}
\tcbuselibrary{skins,breakable}
\definecolor{Info}{rgb}{0.9,0.5,0.0}
\newtcolorbox{Note}[1][i]{
   colback=Info,
   colframe=Info,
   arc=15pt,
   width=\linewidth,
   enhanced jigsaw,
   overlay={
        \begin{scope}[]
            \node[anchor=west,align=center,text width=0.08\linewidth,
                     font=\fontsize{40}{48}\selectfont,text=white] at (frame.west) {$#1$};
        \end{scope}},
   left=0.08\linewidth,
   right=10pt,top=10pt,bottom=10pt,
   fontupper=\bfseries,
%   before=\begin{center},
%   after=\end{center}
   }

\begin{document}
\noindent
\begin{Note}
  This is a test. This is a test.
  This is a test. This is a test.
  This is a test. This is a test.
  This is a test. This is a test.
  This is a test.
\end{Note}
\end{document}

enter image description here

  • Well, that fixed the problem - although I still have no idea why... – MathematicalOrchid Jan 25 '15 at 12:54
  • So... it's aligning the baseline of the "i" to the middle of the paragraph? – MathematicalOrchid Jan 25 '15 at 15:31

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.