Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Using the hvfloat package:

\documentclass[pdftex,10pt,b5paper,twoside]{report} 
\usepackage[showframe,lmargin=25mm,rmargin=25mm,tmargin=27mm,bmargin=30mm]{geometry}
\usepackage[demo]{graphicx}
\usepackage{hvfloat}

\begin{document}

\appendix
\chapter{Test chapter}

\hvFloat[%
floatPos=htb,%
capVPos=c,%
rotAngle=90,
objectPos=c]{figure}{\includegraphics[width=353pt,height=290pt]{image}}%
[Commercial crude oil inventories, SPX excess returns, S\&P GCSI excess return time series]{Commercial crude oil inventories calculated as the logarithm of the current value divided by the mean of same weekly values over the past 5 years, Log excess returns on the S\&P Goldman Sachs Commodity Index,  Log excess returns on the S\&P 500 index.}{fig:test}

\end{document}

can I in any way write a function that automatically rotate the "object" (rotAngle), depending on if the figure is on a even or odd page:

Have tried:

\usepackage{ifthen}
\newcommand{\currentside}{\ifthenelse{\isodd{\thepage}}{270}{90}}

rotAngle = \currentside

But can't get i to work.. Anyone have a suggestion?

share|improve this question
    
the command you created refers to the value of rotAngle, right? (because the value you're using for objectPos is c) –  henrique Jun 6 '11 at 23:27
    
@henrique: true. any suggestion? –  latexmp Jun 6 '11 at 23:32
    
i'm working on it :) –  henrique Jun 6 '11 at 23:54
add comment

2 Answers

I would suggest you to create a command with the \ifthenelse setting the whole \hvFloat stuff, insted of just an argument for one of its options. Something like:

 \hvFloat[floatPos=htb,capVPos=c,rotAngle=90,objectPos=c]% options
     {figure}%     float type
     {\includegraphics[width=353pt,height=290pt]{#1}}%     object: Argument #1 Stands for the image location
     [#2]%     Arg #2 = short caption
     {#3}%     Arg #3 = long caption
     {#4}%     Arg #4 = label
 }{    
 \hvFloat[floatPos=htb,capVPos=c,rotAngle=270,objectPos=c]%     options
     {figure}%     float type
     {\includegraphics[width=353pt,height=290pt]{#1}}%     object: Argument #1 Stands for the image location
     [#2]%     Arg #2 = short caption
     {#3}%     Arg #3 = long caption
     {#4}%     Arg #4 = label
 }
}

(But that didn't work here...)

I managed to do something like without the hvfloat package, but I don't know if it suits your needs:

\newcommand{\currentside}[2]{\ifthenelse{\isodd{\thepage}}{%
  \begin{figure}[htb]%
   \includegraphics[height=\textwidth,angle=270]{#1}%
   \caption{#2}%
  \end{figure}%
 }{%
  \begin{figure}[htb]%
   \includegraphics[height=\textwidth,angle=90]{#1}%
   \caption{#2}%
  \end{figure}%
 }%
}
share|improve this answer
add comment

Define a special key which then takes the label of the image into account with \pageref{..}

\documentclass[b5paper,twoside]{report} 
\usepackage[showframe,lmargin=25mm,rmargin=25mm,tmargin=27mm,bmargin=30mm]{geometry}
\usepackage[demo]{graphicx}
\usepackage{hvfloat}
\makeatletter
\define@key{hvSet}{RotAngle}[]{%
  \ifx\relax#1\relax\def\hvSet@rotAngle{90}\else
    \ifodd\pageref{#1}\def\hvSet@rotAngle{90}\else\def\hvSet@rotAngle{270}\fi\fi}
\makeatother

\begin{document}

\appendix
\chapter{Test chapter}

\hvFloat[%
floatPos=htb,%
capVPos=c,%
RotAngle=fig:test,
objectPos=c]{figure}{\includegraphics[width=300pt,height=290pt]{image}}%
[Commercial crude oil inventories, SPX excess returns, S\&P GCSI excess return time series]{Commercial crude oil inventories calculated as the logarithm of the current value divided by the mean of same weekly values over the past 5 years, Log excess returns on the S\&P Goldman Sachs Commodity Index,  Log excess returns on the S\&P 500 index.}{fig:test}

\clearpage

\hvFloat[
floatPos=htb,
capVPos=c,
RotAngle=fig:testA,
objectPos=c]{figure}{\includegraphics[width=353pt,height=290pt]{image}}%
[Commercial crude oil inventories, SPX excess returns, S\&P GCSI excess return time series]{Commercial crude oil inventories calculated as the logarithm of the current value divided by the mean of same weekly values over the past 5 years, Log excess returns on the S\&P Goldman Sachs Commodity Index,  Log excess returns on the S\&P 500 index.}{fig:testA}

\clearpage

\hvFloat[
floatPos=htb,
capVPos=c,
RotAngle=,
objectPos=c]{figure}{\includegraphics[width=353pt,height=290pt]{image}}%
[Commercial crude oil inventories, SPX excess returns, S\&P GCSI excess return time series]{Commercial crude oil inventories calculated as the logarithm of the current value divided by the mean of same weekly values over the past 5 years, Log excess returns on the S\&P Goldman Sachs Commodity Index,  Log excess returns on the S\&P 500 index.}{fig:testB}
\end{document}
share|improve this answer
    
@Herbert: When I try to add more firgure, i get: Appendix A. ! Missing number, treated as zero. <to be read again> \protect l.19 ...graphics[width=300pt,height=290pt]{image}} % ? Any idea why? –  latexmp Jun 7 '11 at 7:51
1  
@latexmp: I modified the example to allow RotAngle= with an empty argument. In this case rotAngle=90 is assumed. However, you need for every image a label, otherwise \pageref won't work. We need this, because \ifodd\thepage didn't work in all cases. –  Herbert Jun 7 '11 at 8:16
    
@Herbert: thnks! Just one more question... Is it hard to make the horizontalplacement (objectPos) to left (l) on even pages and right (r) on odd pages? –  latexmp Jun 7 '11 at 8:47
    
@latexmp: no, you can do it in the same way as for RotAngle. Define a new key ObjectPos which uses the same \pageref{#1} for setting objectPos. It is also possible to set this inside the RotAngle key itself. –  Herbert Jun 7 '11 at 9:11
    
@Herbert: ok. If i try to make the image wider and higher, it sometimes jump to a new page, but do not rotate the right way. Also i struggle to get a figure at the same page as the heading if i try to make it wider. What i like is to use the full height of the page (width of figure) and adjust the width (height of the figure) so it fit the page, including the caption... –  latexmp Jun 7 '11 at 9:34
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.