3

everybody. I need to enclosure a text block into big square brackets. Something like this (I need to replicate it, more or less): enter image description here

I've read that it could be possible with tikz but I don't know anything about that package. Even, I found a code that reproduce something similar but with braces in this post: Adding a large brace next to a body of text The code is this:

\documentclass{article}
\usepackage{lipsum}
\usepackage[many]{tcolorbox}
\usetikzlibrary{decorations.pathreplacing}

\newtcolorbox{rightbrace}{%
    enhanced jigsaw, 
    breakable, % allow page breaks
    frame hidden, % hide the default frame
    overlay={%
        \draw [
            fill=none, % fill paper
            decoration={brace,amplitude=0.5em},
            decorate,
            ultra thick,
            gray,
        ]
        % right line
        (frame.north east)--(frame.south east);
    },
    % paragraph skips obeyed within tcolorbox
    parbox=false,
}

\begin{document}

\begin{itemize}
    \item First line
          \begin{rightbrace}
            \item Second line 
            \item Third line, which is quite long and seemingly tedious in the extreme
            \item Fourth line, which isn't as long as the third 
          \end{rightbrace}
    \item Fifth line
\end{itemize}

\begin{rightbrace}
    \lipsum[1]
\end{rightbrace}
\lipsum[2]

\end{document}

How could I put the square brackets around a block of text? (Using tikz, tcolobox or whatever package then can be useful for it).

Thanks for your help.

6

I adapted the code to match your picture.

This is the output:

enter image description here

And the code is:

\documentclass{article}

\usepackage{lipsum}
\usepackage[many]{tcolorbox}

\newtcolorbox{squarebrackets}[2][]{%
  empty,
  breakable,
  boxsep=0pt,boxrule=0pt,left=5mm,right=5mm,
  toptitle=3mm,bottomtitle=1mm,
  title=\colorbox{yellow}{#2},
  coltitle=black,
  fonttitle=\bfseries,
  underlay={%
    \draw[gray!50,line width=1mm]
      ([xshift=5mm,yshift=-0.5mm]frame.north west)--
      ([xshift=0.5mm,yshift=-0.5mm]frame.north west)--
      ([xshift=0.5mm,yshift=0.5mm]frame.south west)--
      ([xshift=5mm,yshift=0.5mm]frame.south west)
      ([xshift=-5mm,yshift=-0.5mm]frame.north east)--
      ([xshift=-0.5mm,yshift=-0.5mm]frame.north east)--
      ([xshift=-0.5mm,yshift=0.5mm]frame.south east)--
      ([xshift=-5mm,yshift=0.5mm]frame.south east)
      ;
  },
  % paragraph skips obeyed within tcolorbox
  parbox=false,#1
}

\begin{document}

\lipsum[1]

\begin{squarebrackets}{Corolario}
  \lipsum[2]
\end{squarebrackets}

\lipsum[3]

\end{document}
  • Thanks, Thomas. Your code worked!! Now, I have a new problem: in several "Corolarios" I have to insert an image between two paragraph and, when I make the corolario in the squarebrackets environment, the figure environment doesn't work. So, I had to put the images ( \includegraphics) in a minipage environment. So, I lost the possibility to use \caption for automatically numbering. How could I to modify this code in order to the possiblity to use the figure environment? – Fabio Aug 4 '17 at 4:12
  • @Fabio For non-floating environments, you can use \captionof from the caption package, see e.g. tex.stackexchange.com/questions/45073/… – Thomas F. Sturm Aug 4 '17 at 7:29

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.