
Tengo este código en un documento:
\begin{figure}
\center
\includegraphics[scale=0.5]{images/image.jpg}
\caption{image}
\end{figure}
The content of file.sh :
\begin{figure}
\lstinputlisting[language=Bash,caption={mycaption}]{file.sh}
\end{figure}
Blablabla
El código fuente se coloca después del texto.Bla bla blay en una sola página. Este texto contiene un texto clásico, una sección. Debe colocarse justo después de la imagen. Además, el código fuente se corta al final de la página y le falta la mitad del código... Estos son los registros:
<images/image.jpg, id=122, 442.65375pt x 492.84125pt>
File: images/image.jpg Graphic file (type jpg)
<use images/image.jpg>
Package pdftex.def Info: images/image.jpg used on input line 292.
(pdftex.def) Requested size: 221.32632pt x 246.42001pt.
(/usr/share/texlive/texmf-dist/tex/latex/listings/lstlang1.sty
File: lstlang1.sty 2015/06/04 1.6 listings language file
)
(/usr/share/texlive/texmf-dist/tex/latex/listings/lstlang1.sty
File: lstlang1.sty 2015/06/04 1.6 listings language file
)
Package hyperref Info: bookmark level for unknown lstlisting defaults to 0 on i
nput line 298.
LaTeX Font Info: Try loading font information for T1+cmtt on input line 298.
(/usr/share/texlive/texmf-dist/tex/latex/base/t1cmtt.fd
File: t1cmtt.fd 2014/09/29 v2.5h Standard LaTeX font definitions
)
(./file.sh)
LaTeX Warning: Float too large for page by 705.87885pt on input line 299.
[9]
Me estoy volviendo loco. Espero que me pueda ayudar.
Respuesta1
Si se supone que LaTeX debe mantener el orden estricto listado de imágenes-Blablabla, no utilice ningún figure
entorno. Todo lo que envuelvas en un entorno de figuras tendrá una cierta inclinación a moverse hacia donde TeX crea que encaja mejor; además, el contenido de un figure
entorno no se divide en páginas.
\documentclass{article}
\usepackage{caption}% For the \captionof command, to be used outside of figures
\usepackage{graphicx}
\usepackage{listings}
\begin{document}
\begin{center}
\includegraphics[scale=0.5]{example-image}
\captionof{figure}{image}
\end{center}
The content of file.sh :
\lstinputlisting[language=Bash,caption={mycaption}]{file.sh}
Blablabla
\end{document}