Graphics, Figures & TablesGenerate textbox on same page from within figure environment

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
ralphwadams
Posts: 2
Joined: Fri Aug 28, 2009 10:56 am

Generate textbox on same page from within figure environment

Post by ralphwadams »

My thesis requires that any pages that have color components have "original in color" at the top of the page, the way I see it there are two ways of doing this, renewing the header command for each of these pages or inserting a textblock at the top of any of these pages.

I went with the latter as it seemed more straight forward using:

Code: Select all

\newcommand{\colorfig}{
\protect{\begin{textblock}{6}(0,0)
\begin{center}
original in color	
\end{center}
\end{textblock}}
}
in the preamble and then calling

Code: Select all

\colorfig
from within any figure environment that has a color image, eg

Code: Select all

\begin{figure}[htbp]
	\centering
		\includegraphics[width=0.8\textwidth]{img/03.eps}
	\caption[TOC caption]{caption}
	\label{fig:img03}
        \colourfig
\end{figure}
This works nicely except when latex pushes the figure to the top of the following page from which it is defined in which case "original in color" appears on the previous page, not on the same page as the figure where I want it.

Is there a way round this - am I trying to do something in a complicated way that can be done quite simply?

I have tried "\protect{\colorfig}" and moved the \colorfig command within the figure environment to no avail.

Thanks in advance for any assistance.

Ralph

I'm using the following packages (along with several others)

Code: Select all

\usepackage{fancyhdr}

\usepackage[absolute]{textpos}
\setlength{\TPHorizModule}{10mm}
\setlength{\TPVertModule}{\TPHorizModule}
\textblockorigin{75mm}{13mm}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Generate textbox on same page from within figure environment

Post by gmedina »

Hi,

you can use the \iffloatpage, \iftopfloat, \ifbotfloat commands provided by the fancyhdr package; please refer to Section 14 "Special page layout for float pages" (pages 14-15) of the package documentation.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
ralphwadams
Posts: 2
Joined: Fri Aug 28, 2009 10:56 am

Generate textbox on same page from within figure environment

Post by ralphwadams »

Thanks for the reply, I think that method will influence all pages with floats on, not just the ones in color.

According to the fancyhdr documentation:
Marks in floats will not be visible in LATEX’s output routine, so it is not useful to put marks in floats. So there is currently no way to let a float (e.g. a figure caption) influence the page header or footer.
I think this means that using a renew command with the header wont work (but I'm probably wrong). I have been able to trick latex by moving the code for the figure command around which doesn't change their position in the document but does change the page on which the text box appears. This isn't ideal as I'll have to check through the final draft but I suppose it will suffice if there isn't a definite solution. It only occurs on five or six of the images so it isn't a major problem.

R
Post Reply