1

I'm now using framed package, and the output looks good for me. However, if I want all paragraph in this framed environment further indent for 2em, I always manually use \hangindent = 2em\hangafter = 0 at every beginning of a paragraph. But it is quite redundant. Even if I define a new command \newcommand{\allindent}{\hangindent = 2em\hangafter = 0}, it's still so inconvenient. How can I automatically indent the paragraphs in framed? (If there's no a box surrounding it, it is easy to do so.) By the way, the place of the sides of the framed is ideal for me, so I don't want to change it.

\documentclass[12pt,a4paper,openany,fleqn]{book}
\usepackage[margin=2cm, top=2cm]{geometry}
\usepackage{amsmath,framed}
\parindent=0pt
\parskip=3pt
\OuterFrameSep = -4ex
\FrameSep = 7pt
\FrameRule = 1.3pt 

\begin{document}
\begin{framed}
\hangindent = 2em\hangafter = 0 These are some words. These are some words. These are some words. These are some words. These are some words. These are some words. These are some words.These are some words. These are some words. These are some words. These are some words. These are some words. These are some words.

\hangindent = 2em\hangafter = 0 These are some words. These are some words. These are some words. These are some words. These are some words. These are some words. These are some words.These are some words. These are some words. These are some words. These are some words. These are some words. These are some words. 

If I don't use the \verb"\hangindent" and \verb"\hangafter", the indentation is not I want.
\end{framed}
\end{document} 

enter image description here

1 Answer 1

2

Switch to mdframed.

A simple innerleftmargin declaration should do what you want.

MWE:

\documentclass[12pt,a4paper,openany,fleqn]{book}
\usepackage[margin=2cm, top=2cm]{geometry}
\usepackage{amsmath,mdframed}
\parindent=0pt
\parskip=3pt

\begin{document}
\begin{mdframed}[innerleftmargin=2em,linewidth=1.3pt]
These are some words. These are some words. These are some words. These are some words. These are some words. These are some words. These are some words.These are some words. These are some words. These are some words. These are some words. These are some words. These are some words.

These are some words. These are some words. These are some words. These are some words. These are some words. These are some words. These are some words.These are some words. These are some words. These are some words. These are some words. These are some words. These are some words.

If I don't use the \verb"\hangindent" and \verb"\hangafter", the indentation is not I want.
\end{mdframed}
\end{document}

Output:

enter image description here


EDIT

To have top and bottom lines when the mdframed breaks a page use the option everyline=true.

Eventually act on the options splitbottomskip and splittopskip and set the options globally through \mdfsetup.

Example:

\documentclass[12pt,a4paper,openany,fleqn]{book}
\usepackage[margin=2cm, top=2cm]{geometry}
\usepackage{amsmath,mdframed}
\mdfsetup{everyline=true,splittopskip=15pt,innerleftmargin=2em,linewidth=1.3pt}
\usepackage{lipsum}
\parindent=0pt
\parskip=3pt

\begin{document}
\begin{mdframed}
These are some words. These are some words. These are some words. These are some words. These are some words. These are some words. These are some words.These are some words. These are some words. These are some words. These are some words. These are some words. These are some words.

These are some words. These are some words. These are some words. These are some words. These are some words. These are some words. These are some words.These are some words. These are some words. These are some words. These are some words. These are some words. These are some words.

If I don't use the \verb"\hangindent" and \verb"\hangafter", the indentation is not I want.
\lipsum[1-10]
\end{mdframed}
\end{document} 

Output:

enter image description here

3
  • Thanks! It looks good. Another question: if I want mdframed "enclose" the box by the bottom (and top) line in every page when the box is too height so that crossing pages occurs, how can I do?
    – Eric
    Jun 17, 2017 at 11:46
  • 1
    @Eric See the edit. Jun 17, 2017 at 18:35
  • @Eric Happy to help! Jun 18, 2017 at 8:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .