rstudio/rmarkdown-cookbook

9.6.3 infobox code

Opened this issue · 4 comments

In 9.6.3 it appears there is an error in the following code. The image appears outside of the blackbox not inside. Although I'm playing around to find a solution myself, I wonder if someone can provide a correction quicker than I can figure it.

 \newenvironment{infobox}[1]
   {
   \begin{itemize}
   \renewcommand{\labelitemi}{
     \raisebox{-.7\height}[0pt][0pt]{
       {\setkeys{Gin}{width=3em,keepaspectratio}
         \includegraphics{images/#1}}
     }
   }
   \setlength{\fboxsep}{1em}
   \begin{blackbox}
   \item
   }
   {
   \end{blackbox}
   \end{itemize}
   }

Got it. Here is the solution.

 \newenvironment{infobox}[1]
   {
   \begin{blackbox}
   \begin{itemize}
   \renewcommand{\labelitemi}{
     \raisebox{-.7\height}[0pt][0pt]{
       {\setkeys{Gin}{width=3em,keepaspectratio}
         \includegraphics{images/#1}}
     }
   }
   \setlength{\fboxsep}{1em}
   \item
   }
   {
   \end{itemize}
   \end{blackbox}
   }
cderv commented

This is how it looks like in current PDF book I believe
image

I believe this is expected for us that the icon is not inside the blackbox... @yihui I don't have the printed version with me, but is there any change ?

You could indeed put inside the blackbox, and glad you found the solution BTW.

oh that looks nice too, thanks ! i will do another comparison and make a choice

yihui commented

I believe this is expected for us that the icon is not inside the blackbox... @yihui I don't have the printed version with me, but is there any change ?

@cderv That's what we have in the printed version. The icons are not inside the boxes.

@jdambroise Thanks for sharing the solution!