hvfloat 的新命令

hvfloat 的新命令

使用 hvfloat 包:

\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}

我是否可以以任何方式编写一个函数来自动旋转“对象”(rotAngle),具体取决于图形是在偶数页还是奇数页:

试过:

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

rotAngle = \currentside

但我无法工作。有人有什么建议吗?

答案1

定义一个特殊的键,然后使用以下方式考虑图像的标签:\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}

答案2

我建议你创建一个命令来\ifthenelse设置所有\hvFloat内容,而不是只设置其中一个选项的参数。例如:

 \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
 }
}

(但这在这里不起作用......)

我设法做了类似的事情没有hvfloat包,但我不知道它是否适合您的需求:

\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}%
 }%
}

相关内容