I've some minipage
in my document and the parindent
reset automatically in this environment.
After some research, I've found a solution in this topic that I want to improve.
My goal :
- Redefine
minipage
to set parindent automatically as proposed by touhami.
My questions :
- How change the
minipage
environment (with\makeatletter
) to redefine preamble ofminipage
as :
\saveparinfos
\begin{minipage}{0.5\linewidth}
\useparinfo
\end{minipage}
-
Is it bad use to force indent in
minipage
environment and in which case is it wrong ? The topic here had already asked this question but there are no answer. -
More globally, how/where can I know the details of an environment defined in
LaTeX
in order to change it ? I've already modify some environment defined in package where i could read the code in the documentation but forminipage
environment, I'm not able to find where this environment is defined.
Thank you for you help and sorry if there is some english mistakes.
MWE :
\documentclass[11pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{lipsum}
%%Command to set indentation in minipage
\newcommand{\saveparinfos}{%
\edef\myindent{\the\parindent}%
\edef\myparskip{\the\parskip}}
\newcommand{\useparinfo}{%
\setlength{\parindent}{\myindent}%
\setlength{\parskip}{\myparskip}}
\begin{document}
\section{My section}
\subsection{Example of indented text and non-indented in minipage}
\lipsum[1-2]
\vspace{0.2cm}
\noindent\saveparinfos\begin{minipage}{0.48\linewidth}
This is a long text to fill the line untill a linebreak appears.
And there is no indent for each paragraph.
\end{minipage}\hfill
\begin{minipage}{0.48\linewidth}\useparinfo
\lipsum[2]
And this minipage has indentation for each paragraph.
\end{minipage}
\end{document}
Best Answer
You can find the source code of LaTeX in source2e. In TeX Live, the command
texdoc source2e
opens the corresponding PDF document; then you can use the search function of your PDF viewer or the index to find what you are looking for (e.g., commented source code forminipage
).Another way is to look at the file
latex.ltx
that should be part of your TeX distribution, but it has no comments.latex.ltx
is the compilation of many files, with comments removed. The source file forminipage
is calledltboxes.dtx
, you may have it if you have source code for your TeX distribution.If you look in one of these files, you'll see that
\parindent
and\parskip
are both set to zero inside a minipage (\@parboxrestore
is called from\@iiiminipage
, which is itself called directly and indirectly from\minipage
). Therefore, if you see indentation for text inside a minipage, it is either out of the minipage (which is a box) or has been switched on explicitly inside (these two possibilities are visually different, of course).I believe the following expanded version of your example should help you understand this and do more or less what you want. Note the use of
\xdef
instead of\edef
inside the definition of\saveparinfo
. This way, you can do things likewhich would otherwise cause an error, because with
\edef
, the macros used to store the saved parameters would only be defined inside the group.\xdef
makes these macros\global
, just like macros defined with\newcommand
. Now, the full example I promised. :-)Page 1
Page 2
Page 3