在框环境中设置段落左边距

在框环境中设置段落左边距

我现在正在使用framed包,输出对我来说看起来不错。但是,如果我想在此framed环境中进一步缩进所有段落2em,我总是\hangindent = 2em\hangafter = 0在每个段落的开头手动使用。但这很冗余。即使我定义了一个新命令\newcommand{\allindent}{\hangindent = 2em\hangafter = 0},它仍然很不方便。我怎样才能自动缩进段落framed?(如果没有围绕它的框,这样做很容易。)顺便说一句,两侧的位置framed对我来说很理想,所以我不想改变它。

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

在此处输入图片描述

答案1

切换到mdframed

一个简单的innerleftmargin声明应该可以实现你想要的效果。

梅威瑟:

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

输出:

在此处输入图片描述


编辑

要在mdframed分页时显示顶线和底线,请使用选项everyline=true

最终根据选项splitbottomskip和采取行动splittopskip并通过全局设置选项\mdfsetup

例子:

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

输出:

在此处输入图片描述

相关内容