0

As shown below, tables and figures seem to add extra space at the bottom:

enter image description here

In the example below the problem persist also using float (\intextsep was multiplied by 1.5 \baselineskip for better readability):

enter image description here

Code for the first image:

\documentclass[a4paper,12pt]{article}
\usepackage[demo]{graphicx}

\begin{document}

\noindent AAAAAAAAAAAAAAAAAAAAAAAA

\begin{table}[h] \begin{tabular}{c} \hline table \ \hline \end{tabular} \end{table}

\noindent BBBBBBBBBBBBBBBBBBBBBBBB

\begin{table}[h] \vspace{-\baselineskip} \begin{tabular}{c} \hline table \ \hline \end{tabular} \vspace{-\baselineskip} \end{table}

\noindent CCCCCCCCCCCCCCCCCCCCCCCC

\begin{figure}[ht] \includegraphics{demo} \end{figure}

\noindent DDDDDDDDDDDDDDDDDDDDDDDD

\begin{figure}[!ht] \vspace{-\baselineskip} \includegraphics{demo} \vspace{-\baselineskip} \end{figure}

\noindent EEEEEEEEEEEEEEEEEEEEEEEE

\end{document}

Polizi8
  • 311
  • 1
  • 13
  • 1
    https://tex.stackexchange.com/a/23316/197451 – js bibra Mar 22 '21 at 15:37
  • @jsbibra already tried, no change except for \intextsep, which modifies both – Polizi8 Mar 22 '21 at 15:44
  • your question isn't very clear you say "seem to add extra space" but you answer this in your own question, latex (for h position) adds \intextsep before and after the float. – David Carlisle Mar 22 '21 at 15:52
  • if you want no space, do not want the float to move and have no captions, you can simply remove the figure and table environments. – David Carlisle Mar 22 '21 at 15:53
  • @DavidCarlisle the code I posted is a MWE to reproduce the issue, the final look will be the one in the second picture. My question is why the bottom space is different from the top one, you can see that along \intextsep something else is adding space. Even after removing the two \intextsep there is a bit of space left under the figures/tables – Polizi8 Mar 22 '21 at 16:18
  • sorry your example doesn't set intextsep or remove it?, if intextsep is 0 latex adds no space although the standard \baselineskip or \lineskip spaces will be added as for any content. You don't supply code for the second image, I assume your FONTE text is from \caption? but it is hard to comment on that at all. perhaps \caption is adding space below (there is a standard \belowcaptionskip – David Carlisle Mar 22 '21 at 16:35
  • @DavidCarlisle my code refers to the first image because I would like people to focus on it. The second image is only a proof that the extra bottom space is somehow linked to \intextsep. However, setting it to zero makes everything a mess, you get overlapping lines if you try. My goal is fixing the issue for the first image, and then apply the change to the second one myself. Caption doesn't add any extra space below it by default, and I can't fix it with negative \belowcaptionskip, that's why I posted a MWE without \caption, in order to focus on less code. – Polizi8 Mar 22 '21 at 16:45
  • you would not normally get overlapping lines with intextsep=0pt, obviously your example code produces overlapping as it inserts negative space. If you don't insert negative space and set intextsep to 0pt latex macros insert no extra space so you are probably just seeing \lineskip which is 1pt by default. I would try to post an answer but I am really still not sure what the question is. – David Carlisle Mar 22 '21 at 16:49

1 Answers1

2

If you set the space around here floats to 0pt and remove the negative spacing added in the example you get

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage[demo]{graphicx}

\setlength\intextsep{0pt} \setlength\lineskip{0pt}

\showoutput \begin{document}

\noindent AA

\begin{table}[h] \begin{tabular}{c} \hline table \ \hline \end{tabular} \end{table}

\noindent BB

\begin{table}[h] \begin{tabular}{c} \hline table \ \hline \end{tabular} \end{table}

\noindent CC

\begin{figure}[ht] \includegraphics{demo} \end{figure}

\noindent DD

\begin{figure}[!ht] \includegraphics{demo} \end{figure}

\noindent EE

\end{document}

looking in the log you see the vertical space after the first table before BB is

...\penalty 0
...\glue 0.0
...\glue 0.0 plus -1.0
...\penalty 10000
...\glue(\parskip) 0.0 plus 1.0
...\glue(\baselineskip) 6.3

so standard baselineskip spacing as between lines of a paragraph, similarly before CC

....\glue 0.0
...\penalty 0
...\glue 0.0
...\glue 0.0 plus -1.0
...\penalty 10000
...\glue(\parskip) 0.0 plus 1.0
...\glue(\baselineskip) 6.3

DD and EE are the same.

David Carlisle
  • 757,742
  • I see, but how can I remove the vertical space between the first table and BB? Is there a \vspace lenght or similar I can enter within the table/figure environment to get rid of it and have a symmetical top/bottom spacing? – Polizi8 Mar 22 '21 at 17:13
  • 1
    @Polizi8 sorry I just do not understand. As I showed it is just baselineskip, so if the table ended with a row of letters with descenders like gygygygyggy and the BBB were capitals, or even accented capitals, they would over-print if you put them any closer together. It is exactly the same as asking about the space between lines of a paragraph, if you use all lowercase letter with no descenders it looks like there is extra space. – David Carlisle Mar 22 '21 at 17:20
  • 1
    @Polizi8 If you really want that you can use \nointerlineskip \noindent BB – David Carlisle Mar 22 '21 at 17:22
  • Thank you, so the small space in the first picture it was that kind of skip. I fixed the issue in my second image by adding \vspace*{-1.5\baselineskip} before closing the environment. Now I can freely set \intextsep to what I want to regulate the same space before and after a table/figure – Polizi8 Mar 22 '21 at 18:09