Graphics, Figures & TablesReducing distance / spacing between floats and text

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
workerbee
Posts: 43
Joined: Sat Nov 22, 2008 1:53 am

Reducing distance / spacing between floats and text

Post by workerbee »

Hi there, another Latex question.

I tried using the command \intextsep with \setlength to readjust the distance/spacing between floats and text but for some reason this only affected the distance of the top of the figure and the text when this is supposed to also adjust the bottom. Can anyone explain how I can fix this? Any feedback would be most welcome, thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Reducing distance / spacing between floats and text

Post by phi »

Could you please post a minimal working example? LaTeX definitely inserts an \intextsep space both above and below figures.
workerbee
Posts: 43
Joined: Sat Nov 22, 2008 1:53 am

Re: \intextsep

Post by workerbee »

Sure.

My problem is that the distance between the text and top of the float is a good distance but the spacing following the float is a bit too large for my liking. Using \intextsep ends up placing the float too close at the top to the text but not showing enough of a spacial difference between the bottom of the float and following text (and in some cases the distance even gets larger).

Attached are two screen captures of a before and after.

(after, with \setlength\intextsep{-1.5pt} )

(new images for screen capture)
Attachments
before \intextsep
before \intextsep
before-intextsep2.jpg (64.83 KiB) Viewed 17868 times
after \intextsep
after \intextsep
after-intextsep2.jpg (55.7 KiB) Viewed 17868 times
Last edited by workerbee on Sat Dec 27, 2008 2:33 am, edited 2 times in total.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: \intextsep

Post by localghost »

Show us the corresponding source code of the excerpt the can be seen on the screenshot.


Best regards
Thorsten¹
workerbee
Posts: 43
Joined: Sat Nov 22, 2008 1:53 am

Reducing distance / spacing between floats and text

Post by workerbee »

Sure.

I put the \setlength\intextsep{-1.5pt} command in the preamble, so there's no coding for it by the tables.

My issue with this command is that it seems to affect the top distance much more than it does the bottom.

But here's the source code I used for the tables (it's a little messy):

Code: Select all

\begin{table}[H]
\begin{center}
\begin{small}
\setlength\extrarowheight{1pt}
\begin{tabular}[H]{|c c c|c c c|c c c|c c c|c c c|c c c|}
\hline
\multicolumn{9}{|c}{Categories in Original Data Set} & \multicolumn{9}{|c|}{Categories in Recoded Data Set} \\
\hline
& u1 &&& u2 &&& u3 &&& u1 &&& u2 &&& u3 & \\
\hline
& 1 &&&	2 &&&	3 &&& 0 &&&	1 &&&	2 & \\
& 1 &&&	1 &&&	2 &&& 0 &&&	0 &&&	1 & \\
& 2 &&&	2 &&&	2 &&& 1 &&&	1 &&&	1 & \\
& 2 &&&	3 &&&	4 &&& 1 &&&	2 &&&	3 & \\
\hline
\end{tabular}
\end{small}
\end{center}
\end{table}
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Reducing distance / spacing between floats and text

Post by Juanjo »

Try this code:

Code: Select all

\documentclass{article}

\usepackage{array}

\newlength{\mylen}
\settowidth\mylen{\normalfont\small Categories in Original Data Set}
\newcolumntype{C}{>{\centering\arraybackslash}p{0.33\mylen}}

\begin{document}

The recoded values are shown in the table below.\par\vspace{\intextsep}
\begingroup
   \centering\small
   \setlength\extrarowheight{1pt}
   \begin{tabular}{|*{6}{C|}}
      \hline
      \multicolumn{3}{|c|}{Categories in Original Data Set} 
      & \multicolumn{3}{c|}{Categories in Recoded Data Set} \\
      \hline
      u1 & u2 & u3 & u1 & u2 & u3 \\
      \hline
      1 & 2 & 3 & 0 & 1 & 2 \\
      1 & 1 & 2 & 0 & 0 & 1 \\
      2 & 2 & 2 & 1 & 1 & 1 \\
      2 & 3 & 4 & 1 & 2 & 3 \\
      \hline
   \end{tabular}
   \par\vspace{\intextsep}
\endgroup
\noindent The CATEGORICAL option can be used\ldots

The recoded values are shown in the table below.
\begin{center}
   \centering\small
   \setlength\extrarowheight{1pt}
   \begin{tabular}{|*{6}{C|}}
      \hline
      \multicolumn{3}{|c|}{Categories in Original Data Set} 
      & \multicolumn{3}{c|}{Categories in Recoded Data Set} \\
      \hline
      u1 & u2 & u3 & u1 & u2 & u3 \\
      \hline
      1 & 2 & 3 & 0 & 1 & 2 \\
      1 & 1 & 2 & 0 & 0 & 1 \\
      2 & 2 & 2 & 1 & 1 & 1 \\
      2 & 3 & 4 & 1 & 2 & 3 \\
      \hline
   \end{tabular}
\end{center}
\noindent The CATEGORICAL option can be used\ldots
\end{document}
In the definition of the new column type, you can replace 0.33\mylen by a suitable fixed length. Please observe that:
  • Since the table has no caption, you don't need a table environment. In fact, this environment is the responsible of the extra space you observed.
  • If you want exactly \intextsep vertical space, use the first part of the code. If not, perhaps it may suffice the separation provided by the center environment.
  • If you need additional separation between columns, don't put void columns. You may use columns with specific lengths (as above) or you may change \tabcolsep (half the separation between two consecutive columns).
  • The optional argument of tabular is used for positioning the table relative to eventual text in the same line. Allowed values are t, b and c, so \begin{tabular}[H] is meaningless.
  • In your code, the columns labeled by u3 are wider than those corresponding to u1 and u2.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
workerbee
Posts: 43
Joined: Sat Nov 22, 2008 1:53 am

Re: \intextsep

Post by workerbee »

Thanks so much, Juan! This is much more efficient and beautifully done :)
Post Reply