i've been requested to indent the first paragraph in an environment defined with mdframed
.
i've looked at the question Paragraph indenting in an mdframed environment, and while it provides a workaround, there
really has to be a more subtle way of doing this. (i can't find any indication in
the manual that this facility is provided; an option like [indentfirst = true]
would
be really nice.)
here's the test file:
\documentclass[11pt]{amsbook}
\usepackage{tikz}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{etoolbox}
% define (using mdframed) a highlighted block with a double line on the
% left along the (inside) edge of the text block.
%
\mdfdefinestyle{twolined}{%
leftline=true,rightline=false,topline=false,bottomline=false,%
outerlinewidth=.7pt,innerlinewidth=.7pt,middlelinewidth=2pt,%
outerlinecolor=black,innerlinecolor=black,middlelinecolor=white,%
innerleftmargin=6pt,innerrightmargin=0pt,%
innertopmargin=0pt,innerbottommargin=0pt,%
% splittopskip=0pt,splitbottomskip=0pt.%
skipabove=.5\baselineskip,skipbelow=.5\baselineskip
}
\newmdenv[%
leftline=true,rightline=false,topline=false,bottomline=false,%
outerlinewidth=.7pt,innerlinewidth=.7pt,middlelinewidth=2pt,%
outerlinecolor=black,innerlinecolor=black,middlelinecolor=white,%
innerleftmargin=6pt,innerrightmargin=0pt,%
innertopmargin=0pt,innerbottommargin=0pt,%
% splittopskip=0pt,splitbottomskip=0pt.%
% skipabove=.5\baselineskip,skipbelow=.5\baselineskip%
skipabove=1\baselineskip,skipbelow=.5\baselineskip%
]{linedintro}
% patch the command on which linedintro is based, to try to restore the
% paragraph indentation on the first line.
%
\makeatletter
\patchcmd\mdf@lrbox
{\parindent\z@}{\parindent\normalparindent\relax}{}{}
\makeatother
\begin{document}
\thispagestyle{empty}
\noindent Some unindented random text.
\begin{linedintro}
First paragraph within the lined environment.
Add some text to make it two lines long.
Second paragraph within the lined environment. Make it two lines long.
\end{linedintro}
\noindent Some more unindented random text.
\end{document}
output:
i've tried resetting other instances of \parindent
, but to no effect. (i may just
be looking in the wrong place, but it's not obvious what is the right place.)
if i rename the environment in the definition to xlinedintro
and add a "derivative"
environment
\newenvironment{linedintro}{%
\begin{xlinedintro}
\parindent\normalparindent
\hspace*{\normalparindent}\ignorespaces
}{%
\end{xlinedintro}%
}
this will force the indent on the first paragraph. but the real situation is quite a
bit more complicated, and sometimes there is something else (a marginnote
) that must
come between the beginning of the environment and the actual text, so it's necessary
to be careful with the input to avoid extra unwanted space.
is there a better place to apply a patch? or some other way to accomplish the indentation with more subtlety?