TransWikia.com

Not cut the text of a paragraph in the middle

TeX - LaTeX Asked on September 29, 2021

I have figure like this

begin{figure}[h]
    centering
        includegraphics[width=1columnwidth]{figure1.jpeg}
    caption{text caption here}
    label{fig1}
end{figure}

Before this there is a text, however sometimes it cuts the text of the paragraph and keeps the figure and after it the remainder of the text. How is it possible to make in the whole tex make the text doesn’t be cut as the described situation?

One Answer

Easier to show than explain. @captype is used by caption. intextsep is the same gap used by figure [h].

documentclass{article}
usepackage{graphicx}

makeatletter
newenvironment{myfigure}{begin{trivlist}vskipintextsep
  itembegin{minipage}{columnwidth}def@captype{figure}}%
{end{minipage}vspaceintextsepend{trivlist}}
makeatother

begin{document}
Here is a paragrpahh with a figure in the middle of it
begin{myfigure}
  centering
  includegraphics{example-image}
  caption{Text caption here}
  label{fig1}
end{myfigure}
which is treated like an equation in that the sentence is broken and continues normally.
end{document}

Answered by John Kormylo on September 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP