1

My picture and my section won't be on the same page. I have tried the float package with [H] and [!] and so on but it won't work

\documentclass[a4paper]{report}
\usepackage{float}
\usepackage{geometry}
\usepackage{rotating}
\usepackage{pdflscape}
\usepackage{mwe}


\begin{document}
\newpage

  \appendix

    \section{LabVIEW-kod}
      \begin{sidewaysfigure}[h]
        \includegraphics[height=0.3\textheight]{lab_12.png}
        \caption{}
        \label{fig:big_uppgift}
      \end{sidewaysfigure}
\end{document}

Note from editor

Added packages rotating and pdflscape as I found here to recover from environment sidewaysfigure undefined, and of course I have gotten a file not found error, so I looked for how to use example images, and I found this, and therefore added mwe and used the examples. Here is the resulting output:

enter image description here

(p. 1)

enter image description here

(p. 2)

  • @ArunDebray Isn't this question asking the opposite i.e. how to put it on the current page rather than a new one? – cfr Jan 27 '16 at 23:07
  • @cfr: thank you; that was my mistake. I've retracted my vote. (It's still likely that this has been asked before, though.) – Arun Debray Jan 27 '16 at 23:11
  • @ArunDebray I agree, but it needs to be marked as a duplicate of a question which asks the same thing ;). – cfr Jan 27 '16 at 23:13
  • @cfr I have searched for an answer but didn't find one that said something that helped. The response is often use \usepackage{float} and use [H] But it doesn't work. – rikard Jan 27 '16 at 23:31
  • Perhaps it is just too large for the space? That is the most common reason, I think. – cfr Jan 27 '16 at 23:44
1

You cannot mix some text (section title) and sidewaysfigure on the same page. In your case, if the image is shorter than rest of vertical place on the page and you like to have both on the same page, just can rotate only image:

\documentclass[a4paper]{report}
%\usepackage{float}
\usepackage[margin=25mm,showframe]{geometry}
%\usepackage{rotating}
%\usepackage{pdflscape}
\usepackage{mwe}

\begin{document}

\appendix
\section{LabVIEW-kod}
      \begin{figure}[h]
      \centering
\rotatebox{90}{\includegraphics[height=0.85\textwidth]{example-image}}
        \caption{}
        \label{fig:big_uppgift}
      \end{figure}
\end{document}

enter image description here

Note, in this case figure caption is not rotated width image.

  • You can have a rotated caption by putting the image and \caption inside a \parbox or minipage and rotating the whole thing. It helps to know how wide the image is first. – John Kormylo Jan 28 '16 at 4:25

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.