[comp.text.tex] LaTeX: figure placement and centering

rankin@s3snorkel.ARPA (Tom Rankin) (10/25/90)

I've exhausted all of my patience and resources trying to solve these
problems.  With any luck, someone here can offer salvation.

I am using:
  TeX, C Version 2.93
  LaTeX Version 2.09 - Released 19 April 1986

My source is written using the report style, however, changing to the
book style didn't seem to effect any of my results in the least.  I
haven't tried the article style since I'm using \chapter sectioning
(and article.sty doesn't have \chapter).

Here are my problems:

  1. Location of figures.
  
     I'm attempting to specify that I would like my figures to appear
     "here", as in *right* *here*!, using the following construct:

       \begin{figure}[h]
	 [...contents of figure...] \end{figure}

     The figures are consistently coming up at the *end* of my
     document, not in-line as desired (and as advertised by the "here"
     location specifier).  Very frustrating.  How do I have to hold my
     mouth to get this to work?

  2. Centering the tabbing environment within a figure.

     I'm trying to center a \tabbing environment using either of the
     following constructs:

       \begin{figure}[h] 
       \centering 
       \begin{tabbing}
	 [...tabbing stuff...] 
       \begin{tabbing} 
       \end{figure}

	 OR

       \begin{figure}[h] 
       \begin{center} 
       \begin{tabbing}
	 [...tabbing stuff...] 
       \end{tabbing} 
       \end{center} 
       \end{figure}

     The result is the same in both cases, the material withing the tabbing
     environment ends up left justified.  
     
     I do have a couple of figures that use the tabular environment and
     they center properly using the same two techniques.  Although I could
     probably use the tabular environment in place of the tabbing one I'm
     using, it would be a misuse of the tabular environment (the tabbing
     environment, on the other hand, serves my purpose *exactly* -- except
     I can't get the damn thing centered on the page).

  3. Getting \samepage to work as advertised.

     I've tried on numerous occasions to creat sections of text that are
     delimited on the top and the bottom by \rule lines (used for
     in-line EXAMPLES).  I'd like to get the entire example to appear on a
     single page without stranding part of the example (usually a single
     rule line) on a separate page.  My attempt to get this to happen looks
     like this:

     {\samepage
     \noindent
     \rule{127mm}{.1mm}
     \vspace{-2mm}\\
     {\large \bf EXAMPLE:} Example Title \\
       [...text of example]
     \noindent
     \rule{127mm}{.1mm}
     }

     but the \samepage environment seems to be wholly ignored.  The results
     are the same with or without the \samepage declaration.  By the way,
     these examples are much shorter than a full page, so they should be
     able (at the very least) to be pushed onto the top of a following page.

Hep me, hep me...please!  

Tom Rankin
rankin@scubed.scubed.com
--------------------------------------------------------------------------
Tom Rankin    Maxwell Laboratories, S-CUBED Division   3398 Carmel Mtn Rd.
rankin@scubed.scubed.com      (619) 587-8394           San Diego, CA 92121
--------------------------------------------------------------------------

gampell@hpcc01.HP.COM (David J. Gampell) (10/27/90)

/ hpcc01:comp.text.tex / rankin@s3snorkel.ARPA (Tom Rankin) /  2:39 pm  Oct 24, 1990 /
>I've exhausted all of my patience and resources trying to solve these
>problems.  With any luck, someone here can offer salvation.
>
>I am using:
>  TeX, C Version 2.93
>  LaTeX Version 2.09 - Released 19 April 1986
>
>My source is written using the report style, however, changing to the
>book style didn't seem to effect any of my results in the least.  I
>haven't tried the article style since I'm using \chapter sectioning
>(and article.sty doesn't have \chapter).
>
>Here are my problems:
>
>  1. Location of figures.
>  
>     I'm attempting to specify that I would like my figures to appear
>     "here", as in *right* *here*!, using the following construct:
>
>       \begin{figure}[h]
>	 [...contents of figure...] \end{figure}
>
>     The figures are consistently coming up at the *end* of my
>     document, not in-line as desired (and as advertised by the "here"
>     location specifier).  Very frustrating.  How do I have to hold my
>     mouth to get this to work?

You don't have enough location specifiers to get this to work.  LaTeX requires
that there be enough location specifiers (default tbp) to place the figure
*somewhere*.  If, for example, there isn't enough room on the page for your
figure when LaTeX encounters \begin{figure}[h], it will place your figure at
the end of the current chapter (or when the next \clearpage, \cleardoublepage
or \end{document}) is encountered.  Try \begin{figure}[htbp], which should have
a much higher likelihood of placing your figures correctly.

>  2. Centering the tabbing environment within a figure.
>
>     I'm trying to center a \tabbing environment using either of the
>     following constructs:
>
>       \begin{figure}[h] 
>       \centering 
>       \begin{tabbing}
>	 [...tabbing stuff...] 
>       \begin{tabbing} 
         ^^^^^
	 Presumably you mean \end{tabbing}

>       \end{figure}
>
>	 OR
>
>       \begin{figure}[h] 
>       \begin{center} 
>       \begin{tabbing}
>	 [...tabbing stuff...] 
>       \end{tabbing} 
>       \end{center} 
>       \end{figure}
>
>     The result is the same in both cases, the material withing the tabbing
>     environment ends up left justified.  
>     
>     I do have a couple of figures that use the tabular environment and
>     they center properly using the same two techniques.  Although I could
>     probably use the tabular environment in place of the tabbing one I'm
>     using, it would be a misuse of the tabular environment (the tabbing
>     environment, on the other hand, serves my purpose *exactly* -- except
>     I can't get the damn thing centered on the page).

You have what I think is a mode clash.  The figure environment want to
process stuff in paragraph mode while the tabbing environment processes stuff
in LR mode.  To accomplish what you want, try this...

	\begin{figure}[htbp]
	\begin{minipage}{\textwidth}
	\centering
	\begin{tabbing}
	.
	.
	.
	\end{tabbing}
	\end{minipage}
	\caption{if any}
	\label{if-any}
	\end{figure}

The minipage environment forces whatever's inside it to be processed in
paragraph mode.  This should allow the \centering command to work.

Sorry, I don't know anything about \samepage.

>Tom Rankin
>rankin@scubed.scubed.com
>--------------------------------------------------------------------------
>Tom Rankin    Maxwell Laboratories, S-CUBED Division   3398 Carmel Mtn Rd.
>rankin@scubed.scubed.com      (619) 587-8394           San Diego, CA 92121
>--------------------------------------------------------------------------

Dave Gampell
dave@hpoclpa.hp.com

"Why do you think that I speak for HP?"