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.

I want to place two pictures side by side as subfigures, rotated 90 degrees and those two pictuers filling a whole page.

While this works from the looks I have some issues, with the hyperref package and its targets.

The issues are:

  1. The links from hyperref link to the bottom of the page, I would like them to link to the top left corner of the picture, so I see the piture after clicking the link and not only the page number.
  2. I would like the figure to fill a whole page, how can I make sure the float lands on a page of its own but can float arround? (I use \xhsize which is the space remaining for the float, I assume this is wrong for my case). Note: the newpage here is only for demonstration.

Code

\documentclass{report}
\usepackage{tikz}
\usepackage[hyperindex, colorlinks]{hyperref}
\usepackage{caption}                            
\usepackage[list=on]{subcaption}                            

\usepackage[figuresright]{rotating}             %rotated figures
\usepackage{floatrow}                           %subfigures
\usepackage{adjustbox}      

\floatsetup{style=ruled,footposition=caption,capposition=bottom}   %make graphics look like booktables
\floatsetup[subfigure]{style=plain}
\DeclareCaptionSubType[alph]{figure}
\captionsetup[subfigure]{labelformat=brace,justification=centerlast}
\begin{document}
\newpage
\begin{sidewaysfigure}[h!]
    \centering
    \ffigbox[\FBwidth]{
    \begin{subfloatrow}
        \ffigbox[.5\Xhsize]{\caption{variant a}\label{fig:a}}{\adjustbox{max width={.5\Xhsize}}{\begin{tikzpicture}\node {smaple};\end{tikzpicture}}}
        \ffigbox[\Xhsize]{\caption{variant b}\label{fig:b}}{\adjustbox{max width={\Xhsize}}{\begin{tikzpicture}\node {smaple};\end{tikzpicture}}}       
    \end{subfloatrow}}
    {\caption{flavours}\label{fig}}
\end{sidewaysfigure}
\newpage
\ref{fig} contains: \ref{fig:a} and \ref{fig:b}.
\newpage
\listoffigures
\end{document}
share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

For issue (1), you could use the hycap package. So when you click the link the reference jumps to the figure and not the bottom. As for jumping to the top left, you could probably do some adjustments, but if your goal is to be on the figure, just add:

\usepackage{hyperref}
\usepackage[figure, figure*]{hypcap}

If you add the option [all], it will behave this way for figures, tables, and the float versions *.

Link to hypcap doc: http://texdoc.net/texmf-dist/doc/latex/oberdiek/hypcap.pdf


Adding \capstart directly after \begin{subfloatrow} will have the link to the figure jump to the top and not the bottom where nothing is visible.

\documentclass{report}
\usepackage{tikz}
\usepackage{caption}                            
\usepackage[list=on]{subcaption}                            

\usepackage[figuresright]{rotating}             %rotated figures
\usepackage{floatrow}                           %subfigures
\usepackage{adjustbox}  
\usepackage[hyperindex, colorlinks]{hyperref}
\usepackage[all]{hypcap}    

\floatsetup{style=ruled,footposition=caption,capposition=bottom}   %make graphics look like booktables
\floatsetup[subfigure]{style=plain}
\DeclareCaptionSubType[alph]{figure}
\captionsetup[subfigure]{labelformat=brace,justification=centerlast}
\begin{document}
\newpage
\begin{sidewaysfigure}[h!]
    \centering
    \ffigbox[\FBwidth]{
    \begin{subfloatrow}
    \capstart
        \ffigbox[.5\Xhsize]{\caption{variant a}\label{fig:a}}{\adjustbox{max width={.5\Xhsize}}{\begin{tikzpicture}\node {smaple};\end{tikzpicture}}}
        \ffigbox[\Xhsize]{\caption{variant b}\label{fig:b}}{\adjustbox{max width={\Xhsize}}{\begin{tikzpicture}\node {smaple};\end{tikzpicture}}}       
    \end{subfloatrow}}
    {\caption{flavours}\label{fig}}
\end{sidewaysfigure}
\newpage
\ref{fig} contains: \ref{fig:a} and \ref{fig:b}.
\newpage
\listoffigures
\end{document}
share|improve this answer
    
I am sorry, I don't see any benefit when loading hypcap, even without it the links work fine, except for the rotated image, which does not work with hypcapeither. –  ted Jul 29 '13 at 10:41
    
@ted have you tested the code? This code works with the rotated figure for me. When I click the link to the rotated figure, I am taken to the top of the page the figure is on. –  dustin Aug 1 '13 at 18:18
    
I was lazy and added \usepackage[all]{hypcap} to my main document and did not see the improvement. Either I messed up or my main document has something interferring. I am sorry for not testing it with the mwe afterwards. –  ted Aug 2 '13 at 6:03
add comment

EXTENDED to permit images of non-uniform width and height. All images are scaled to be the same height and constrained, side-by-side, to fit along the user-defined \rowfigurewidth.

I am not addressing the links issue, but instead the request for a full page figure. I adapt the "rowfigure" methodology I developed when answering ted's prior question (Extracting commands from environment).

The meat of the work is, inside the sidewaysfigure environment, to build the figure as

\rowfigurewidth{constrained width of rowfigure} ("package" defaults to \textwidth)

\startrowfigure{first image, tikz, or whatever}

\addrowfigure{second image, tikz, or whatever}

... (more rowfigures can be added to the row)

\finishrowfigure

Then, as an argument to \ffigbox, employ \scaledrowfigure{1} and \scaledrowfigure{2} instead of the raw (unscaled) images. Also, as the optional argument to \ffigbox, use [\rowfigwidth{1}] and [\rowfigwidth{2}] to indicate the width of that particular subfigure figure.

Here is the whole code:

\documentclass{report}
\usepackage{tikz}
\usepackage[hyperindex, colorlinks]{hyperref}
\usepackage{caption}                            
\usepackage[list=on]{subcaption}                            
\usepackage[figuresright]{rotating}             %rotated figures
\usepackage{floatrow}                           %subfigures
\usepackage{adjustbox}      
\usepackage{scalerel}
\usepackage{fp}
\usepackage{stackengine}
\def\stacktype{L}
\usepackage{xcolor}
\newcount\figfracwidthc
\newcount\figwidthc
\newcount\textwidthc
\newcounter{rowfigcount}
\newcounter{rowfigindex}
\newsavebox\compositefig
\newsavebox\subrowfig
\newlength\rowfigwd
\gdef\rowfigwdstring{\textwidth}
\newcommand\rowfigurewidth[1]{\edef\rowfigwdstring{#1}}
\newcommand\startrowfigure[2][0]{%
  \sbox\compositefig{#2}%
  \edef\rowfigstart{#1}%
  \setcounter{rowfigcount}{#1}%
  \addtocounter{rowfigcount}{1}%
  \expandafter\def\csname rowfig\roman{rowfigcount}\endcsname{#2}%
}
\newcommand\addrowfigure[1]{%
  \sbox\compositefig{\scalerel{\usebox{\compositefig}}{$#1$}}%
  \addtocounter{rowfigcount}{1}%
  \expandafter\def\csname rowfig\roman{rowfigcount}\endcsname{#1}%
}
\newcommand\finishrowfigure{%
  \figwidthc=\wd\compositefig%
  \setlength{\rowfigwd}{\rowfigwdstring}%
  \textwidthc=\rowfigwd%
  \FPdiv\scaleratio{\the\textwidthc}{\the\figwidthc}%
  \global\edef\scaleratio{\scaleratio}%
  \getrowfigwidths%
}
\newcommand\scaledrowfigure[1]{%
  \scalebox{\scaleratio}{\scalerel*{%
       $\csname rowfig\romannumeral #1\endcsname$}{%
       $\csname rowfig\roman{rowfigcount}\endcsname$}}%
}
\newcommand\getrowfigwidths{%
  \setcounter{rowfigindex}{\rowfigstart}%
  \sbox{\compositefig}{}%
  \whiledo{\value{rowfigindex} < \value{rowfigcount}}{%
    \stepcounter{rowfigindex}%
    \sbox{\subrowfig}{\scaledrowfigure{\arabic{rowfigindex}}}%
    \sbox{\compositefig}{%
      \usebox{\compositefig}\scaledrowfigure{\arabic{rowfigindex}}}%
    \expandafter\xdef\csname rowfigwdARRAY\roman{rowfigindex}\endcsname{%
      \the\wd\subrowfig}%
  }%
}
\newcommand\rowfigwidth[1]{\csname rowfigwdARRAY\romannumeral #1\endcsname}
\floatsetup{style=ruled,footposition=caption,capposition=bottom}   %make graphics look like booktables
\floatsetup[subfigure]{style=plain}
\DeclareCaptionSubType[alph]{figure}
\captionsetup[subfigure]{labelformat=brace,justification=centerlast}
\columnsep=0pt
\begin{document}
\newpage
\begin{sidewaysfigure}[h!]%
    \gdef\figone{\fbox{\begin{tikzpicture}\node {\stackunder{Sample 1}{!!!}};\end{tikzpicture}}}%
    \gdef\figtwo{\fbox{\begin{tikzpicture}\node {Sample 2xxxx};\end{tikzpicture}}}%
    \gdef\figthree{\fbox{\begin{tikzpicture}\node {Sample 3};\end{tikzpicture}}}%
%%% UNCOMMENT NEXT THREE LINES TO TEST WITH RULES OF KNOWN SIZE
%\gdef\figone{\textcolor{red}{\rule{.5in}{1ex}}}%
%\gdef\figtwo{\rule{.3in}{1ex}}%
%\gdef\figthree{\textcolor{blue}{\rule{.2in}{1ex}}}%
    \centering%
    \ffigbox[\textheight]{%
    \rowfigurewidth{\textheight}%
    \startrowfigure{\figone}%
    \addrowfigure{\figtwo}%
% UNCOMMENT TO TEST THREE BOXES
    \addrowfigure{\figthree}%
    \finishrowfigure%
    \begin{subfloatrow}%
       \ffigbox[\rowfigwidth{1}]{\caption{variant a\label{fig:a}}}%
           {\scaledrowfigure{1}}%
        \ffigbox[\rowfigwidth{2}]{\caption{variant b\label{fig:b}}}%
           {\scaledrowfigure{2}}%
% UNCOMMENT NEXT TWO LINES TO TEST THREE BOXES
        \ffigbox[\rowfigwidth{3}]{\caption{variant c\label{fig:c}}}%
          {\scaledrowfigure{3}}%
    \end{subfloatrow}}%
    {\caption{flavours \the\textheight}\label{fig}}%
\end{sidewaysfigure}
\newpage
\ref{fig} contains: \ref{fig:a}, \ref{fig:b}
% UNCOMMENT NEXT LINE TO TEST THREE BOXES
, and \ref{fig:c}%
.
\newpage
\listoffigures
\newpage
Test to see if scaled rowfigures span textwidth
    \startrowfigure{\figone}
    \addrowfigure{\figtwo}
    \addrowfigure{\figthree}
    \finishrowfigure

\scaledrowfigure{1}%
\scaledrowfigure{2}%
\scaledrowfigure{3}

\rule{\textwidth}{.1ex}

They do.

These were the originals:
\figone\figtwo\figthree
\end{document}

enter image description here

share|improve this answer
add comment

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.