\parindent in figure environment ??

575 views
Skip to first unread message

PJ

unread,
Nov 17, 2006, 9:57:59 AM11/17/06
to LaTeX Users Group
Dear TeX Lovers,

I need to include a code-like material in a document with some of the
lines indented. So I use, e.g.

for $k = 1$ to $n$ do \\
\indent set $x_{k} := k$; \\
end \{for\};%

When I put it into the figure environment (in order to add a caption to
the included code), the \indent command ceases to work. It seems that
\begin{figure} resets the \parindent value to 0. How could I recover
the original value of \parindent?

Thanks for any help on that..

Peter.

C Hanck

unread,
Nov 18, 2006, 3:47:46 AM11/18/06
to LaTeX Users Group
Have you tried replacing \indent with (say) \hspace{1cm}?

Best, Christoph

PJ

unread,
Nov 20, 2006, 6:47:03 AM11/20/06
to LaTeX Users Group
Thanks, this surely works. Another 'brute force' solution is to define
\setlength{\parindent}{1cm} just after \begin{figure}. But, as a matter
of principle, I would like to recover the original value of \parindent,
so that any change in the document class would automatically lead to a
change here..

Best,
Peter.

Hillevi Gavel

unread,
Nov 20, 2006, 7:52:05 AM11/20/06
to LaTeX Users Group

\newlength{\saveindent}
\setlength{\saveindent}{\parindent}

\newcommand{\restoreindent}{\setlength{\parindent}{\saveindent}}


\begin{figure}
\restoreindent
.....

I think this would work.

Hillevi Gavel

PJ

unread,
Nov 21, 2006, 7:53:04 AM11/21/06
to LaTeX Users Group
Thanks. It's a pity that (as it seems) LaTeX does not have any direct
possibility to read values of variables of an outer environment.. :(

Peter.

Reply all
Reply to author
Forward
0 new messages