7

I create a new macro:

\newcommand{\intersection}[1]{%
\par\vspace{\baselineskip}%
\noindent\textbf{\large\bfseries\sffamily #1}\par}

It works perfectly for what I want, but when there is a environment before macro, latex insert two lines:

extra-space

If possible that macro "detects" when exist a figure (or other environments) don't insert a line break?

MWE

\documentclass[a4paper]{article}
\usepackage{caption}
\usepackage{amsmath,amssymb}
\usepackage{chemfig}

\newcommand{\intersection}[1]{%
\addvspace{\baselineskip}%
\noindent\textbf{\large\bfseries\sffamily #1}\par}

\begin{document}

\begin{figure}[h]
\centering
\includegraphics{image.pdf}
\caption{\textbf{a)} En la situación normal...}
\end{figure}

\intersection{Ion-dipolo}
La ley de Coulomb explica las \textbf{\textit{fuerzas ion-dipolo}}, las cuales atraen entre sí a un ion (ya sea un catión o un anión) y a una molécula polar. La intensidad de esta interacción depende de la carga y tamaño del ion así como de la magnitud del momento dipolar y del tamaño de la molécula.

\intersection{Ion-dipolo inducido}
Se dice que el dipolo del átomo (o molécula no polar) es un dipolo inducido porque la separación de sus cargas positiva y negativa se debe a la proximidad de un ion o una molécula polar. La interacción atractiva entre un ion y el dipolo inducido se conoce como interacción \textbf{\textit{ion-dipolo inducido}}.

\end{document}
  • 3
    use \addvspace not \vspace – David Carlisle Dec 15 '13 at 15:15
  • @DavidCarlisle - Why? – Kiyoshi Dec 15 '13 at 16:12
  • 1
    Because addvspace is designed to do exactly what you ask, it looks at the space (if any) just added, and then adds the maximum of the space already there and the space in the argument so you don't get a double space. (If your question had had an example document I would have posted the result of the command:-) – David Carlisle Dec 15 '13 at 16:14
  • @DavidCarlisle: Would this also work around floats (it's a very specific location) and their \belowcaptionskip / \floatsep / \intextsep spaces? – Werner Dec 15 '13 at 16:39
  • @DavidCarlisle - Sorry, I update my question. I replace \vspace but nothing happen. – Kiyoshi Dec 15 '13 at 16:40
5

You should use \addvspace rather than \vspace then the space will combine with space for in text environments such as center or quote. However your space here is coming from a float. Normally floats are top or bottom of a page, in which case the space before your heading would be discarded at the page break. The extra space here is coming because it is an h float. The simplest thing to do is reduce the space around h floats either globally, or just before the heading, for example

\setlength\intextsep{2pt}

The default in article class is 6pt.

  • I think of other possibility. Is it possible do something like if else like other programming languages to decide when use a \intextsep? – Kiyoshi Dec 15 '13 at 18:55
  • @Kiyoshi intextsep is always used, it is inserted at the point latex decides to position the float as a here float rather than top or bottom float, so you can not test within the page – David Carlisle Dec 15 '13 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.