4

How we can specify figure page? For example I want show a figure on top of page 5.

  • I think it is pretty impossible to do it without imposing a lot restrictions on the text flow. For example \begin{document}...\newpage...\newpage...\newpage...\newpage.. ...then @Ambika's code... ...\end{document}. – alfC Apr 23 '15 at 09:41

3 Answers3

3

If you don't know when in the text the desired page will appear, you can use a combination of packages to do what you want:

  • The everypage package adds a hook that you can run at each page
  • The afterpage package lets you insert code into the next page

You can combine those like I did below, so that at every page, the page number is checked, and if its the page that comes before the one you want, then afterpage is used to insert your figure.

(Why does the page number need to be 3 so that the figure goes into page 5 is unclear to me).

\documentclass{article}
\usepackage{everypage}
\usepackage{afterpage}
\usepackage{ifthen}
\usepackage{pgfplots}
\usepackage{lipsum}

\AddEverypageHook{
  \ifthenelse{\value{page}=3}{
    \afterpage{
      \begin{figure}[t]
        \centering
        \begin{tikzpicture}
          \begin{axis}
            \addplot {cos(x)};
          \end{axis}
        \end{tikzpicture}
      \end{figure}
    }
  }{}
}

\begin{document}

\lipsum[1-40]

\end{document}

This might be overkill. I bet there are better ways to do this!

jja
  • 1,813
2

You can just place the figure physically near the text on the page 5 and use the following to get the figure on the top of the page:

\begin{figure}[t]
\includegraphics{fig}
\end{figure}
  • I think the OP doesn't know where in the text, page 5 will start since that depends on how the text will flow. – alfC Apr 23 '15 at 09:39
  • @alfC When the document is in final form it's quite easy to do as suggested here. – egreg Apr 23 '15 at 13:03
0

To force a figure on a specific place you can use the parameter 'H'(ere)

\begin{figure}[H]

Although you can not specify the page number explicitly, the suggestion increases control over the placement of the figure (which still depends on the text around it).

rvaneijk
  • 330
  • How does this guarantee that the figure will appear at the top of page 5? It could be anywhere, depending on the text around it. – Paul Gessler Apr 23 '15 at 12:18