I'm now using mdframed, and I found that the indentation within mdframed environment is weird. For example, when outside that environment, if we use \hspace*{2em} in the second line, the number 1 in the second line is almost directly under the number 5 and 6 in the first line. However, if these two lines are placed in a mdframed, then this time the 1 is right under 5. Why?

\parindent = 0pt
\par \hspace*{2em} 12345678
\par\hangindent=2em\hangafter=0 12345678

enter image description here

1 Answer 1


It is unrelated to mdframed You see the same with

\par \hspace*{2em} 12345678
\par \hspace*{2em}12345678

the middle line has an additional word space as well as the \hspace. Your mdframed example did not have the extra space.

  • I see. Actually, I was testing with Chinese, but when I convert it to a pure LaTeX MWE, I mistakenly use a non-sense example. I'm still testing. By the way, I'm now encountering a new problem: when I use the user command \newcommand{\myindent}{\hangindent=2em\hangafter=0}, then use 12345678\par\myindent 12345678, the second line wouldn't appear. Can you help me figure out why?
    – Eric
    Commented Jun 25, 2017 at 13:28
  • I post a new question here.
    – Eric
    Commented Jun 25, 2017 at 13:50
  • @Eric you need a space after 0 your definition comes to \hangindent=2em\hangafter=012345678 so sets a very big hangafter you want \hangindent=2em\hangafter=0 12345678 to set it to 0 then typeset 123 Commented Jun 25, 2017 at 14:35

You must log in to answer this question.

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