1

I'm stuck on how to format the boxes in code like below:

enter image description here

The adding and indented icon and the green upper-right-hand-corner text "Update" are the issues confusing me how to format.

  • 5
    Well, as usual here, please add the compilable code to your question ... – Kurt Oct 19 '18 at 18:42
  • 3
    Plus you just asked a very similar question before. Wouln't it be better if you proceeded in small steps: get the answer to your previous question, learn a few new tricks from it, and then, if you really do not know how to this one, ask another question? – marmot Oct 19 '18 at 19:02
  • 1
    You probably want to look at tcolorbox and TikZ. – John Kormylo Oct 19 '18 at 19:17
  • @marmot you're right I'll wait to see the other answer first! – user5601 Oct 19 '18 at 19:24
4

Based on box style provided by marmot's in How to make this rectangle with an image on the left?, here you have a box with a litle icon on left margin and an optional update label on the right corner. As I don't know how these boxes should be aligned to the text, I've provided two options:

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

\tcbset{%
    update/.style={%
        overlay app={%
            \begin{tcbcliptitle}
                \node[fill=green, font=\sffamily\bfseries, text=white, anchor=north east] at (frame.north east) {UPDATED};
            \end{tcbcliptitle}
        }
    }
}
\newtcolorbox{imagebox}[3][]{
    enhanced,
%   show bounding box,
    coltitle=black,
    title filled=false,
    colback=gray!20,
    colbacktitle=gray!20,
    boxrule=0.4pt,
    top=2mm,
    bottom=2mm,
    toptitle=2mm,
    left=12mm,
    right=1mm,
    drop fuzzy midday shadow,
    titlerule=-0.1pt,
    fonttitle=\sffamily\bfseries\large,
    fontupper=\sffamily,
    title={#2},
    overlay={ 
        \begin{scope}
        \clip[rounded corners=1mm] ([shift={(-1cm,-.3cm)}]frame.north west) rectangle coordinate (center) ++(2cm,-2cm);
        \node at (center) {\includegraphics[ width=2cm, height=2cm]{#3}};
        \end{scope}
    },
    #1
}

\begin{document}
\lipsum[1]

\begin{imagebox}{some title}{example-image-duck}
\lipsum[2] 
\end{imagebox}

\begin{imagebox}[enlarge left by=1cm, width=\linewidth-1cm, update]{some title}{example-image-duck}
\lipsum[2]
\end{imagebox}

\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.