Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

What I'm trying to achieve is to get the following effect for a body of text:

image with wanted effect.

I've looked at many examples that use all sort of brackets, but none of them look like the ones above. So far, I've only managed to get a simple frame using mdframed, but that's far from what I hope to get.

\documentclass{memoir}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}
\usepackage{fullpage}

\begin{document}
\begin{mdframed}
\lipsum[1]
\end{mdframed}
\end{document}

Any ideas?

share|improve this question
    
Take a look at mdframed : ctan.org/tex-archive/macros/latex/contrib/mdframed –  projetmbc Feb 11 at 22:48

2 Answers 2

up vote 26 down vote accepted

You have, at least two options allowing page breaks inside the framed text. You can use the tcolorbox package:

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{most}
\usepackage{lipsum}

\newtcolorbox{mybox}{
freelance,
breakable,
frame code={
  \draw 
    ([xshift=2cm]frame.north west) --
    (frame.north west) --
    (frame.south west) --
    ([xshift=2cm]frame.south west);
  \draw 
    ([xshift=-2cm]frame.north east) --
    (frame.north east) --
    (frame.south east) --
    ([xshift=-2cm]frame.south east);
  },
colback=white
}

\begin{document}

\lipsum[4]
\begin{mybox}
\lipsum[4]
\end{mybox}
\lipsum[4]

\end{document}

enter image description here

or you can use the mdframed package:

\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}

\newmdenv[
  hidealllines=true,
  singleextra={
  \draw 
    ([xshift=2cm]O) --
    (O) --
    (O|-P) --
    ([xshift=2cm]O|-P);
  \draw 
    ([xshift=-2cm]P) --
    (P) --
    (P|-O) --
    ([xshift=-2cm]P|-O);
  },
  firstextra={
  \draw 
    (O) --
    (O|-P) --
    ([xshift=2cm]O|-P);
  \draw 
    ([xshift=-2cm]P) --
    (P) --
    (P|-O);
  },
  middleextra={
  \draw 
    (O) --
    (O|-P);
  \draw 
    (P) --
    (P|-O);
  },
  secondextra={
  \draw 
    ([xshift=2cm]O) --
    (O) --
    (O|-P);
  \draw 
    (P) --
    (P|-O) --
    ([xshift=-2cm]P|-O);
  },
]{mybox}

\begin{document}

\lipsum[4]
\begin{mybox}
\lipsum[4]
\end{mybox}
\lipsum[4]

\end{document}

enter image description here

share|improve this answer
    
Boy, you're fast! This is a perfect solution - THANK YOU. –  m0squito Feb 5 at 3:59
    
@m0squito You're welcome! I edited my answer adding the breakable key, so page breaks are allowed inside the environment. –  Gonzalo Medina Feb 5 at 4:02
    
That's even better, thank you very much! –  m0squito Feb 5 at 4:03
    
@m0squito I added another option to my answer, this time using mdframed. Both options will admit page breaks, but the behaviour of the frame when it spans several pages is different as I set the environments; one can easily modify either of the examples to get the same resul as with the other. –  Gonzalo Medina Feb 5 at 4:19

Here I make \specbox a macro, rather than an environment, which means that the bracketed text cannot break across a page. One uses \fboxsep and \fboxrule to define the bracket offset and thickness, and \bracketarm to define the length of the bracket arm.

I use \xcolor and stackengine packages to essentially stack white centered rules above and below \frameboxed text.

\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\usepackage{xcolor}
\usepackage{lipsum}
\newlength\bracketarm
\newlength\fbrp
\fboxsep 2ex
\fboxrule 2pt
\bracketarm 1in
\setlength{\fbrp}{\fboxrule+1pt}
\newcommand\specbox[1]{%
  {\centering\noindent\setstackgap{S}{-\fbrp+0.5pt}%
  \stackon{%
    \stackunder{\framebox{\parbox{\textwidth-2\fboxsep-2\fboxrule}{#1}}}%
      {\color{white}\rule{\textwidth-2\bracketarm}{\fbrp}}%
  }{%
    \color{white}\rule{\textwidth-2\bracketarm}{\fbrp}%
}}}%
\parskip 1ex
\begin{document}
\lipsum[1]

\specbox{\lipsum[2]}

\lipsum[3]
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.