4

This was intended to be an answer to this question. OTOH, it might be possible to improve upon it using eforms or better \href options.

The idea is to first create a PDF file containing the subtables.

\documentclass[multi=subtable]{standalone}
\usepackage{siunitx}
\usepackage{hyperref}

\newenvironment{subtable}[2]% #1 = target name, #2 = tabular columns
{\hypertarget{#1}\bgroup\begin{tabular}{#2}}% body goes here
{\end{tabular}\egroup}

\begin{document}

\begin{subtable}{first}{S|S}
\multicolumn{2}{c}{First}\\
{x} & {y}\\
\hline
1.0 & 3.2\\
1.5 & 2.9
\end{subtable}

\begin{subtable}{second}{S|S}
\multicolumn{2}{c}{Second}\\
{x} & {y}\\
\hline
1.0 & 3.2\\
1.5 & 2.9
\end{subtable}

\end{document}

Then use \href to link this file (test6.pdf) to the main document. Note the use of \# to add the anchors.

\documentclass{article}
\usepackage[colorlinks]{hyperref}

\begin{document}
\begin{table}
  \belowcaptionskip=\abovecaptionskip
  \abovecaptionskip=0pt
  \caption{Main Table - click entries}
  \centering
  \begin{tabular}{cc}
    &\href[pdfnewwindow]{test6.pdf\#first}{First} \\% note {first} is the target name
    \href[pdfnewwindow]{test6.pdf\#second}{Second}
  \end{tabular}
\end{table}
\end{document}

Note that each subtable starts up a new PDF viewer, so you can return by closing the page.

John Kormylo
  • 79,712
  • 3
  • 50
  • 120

1 Answers1

2

Here is a version which puts all the subtables into an appendix, using just \label and \ref. Presumably the actual subtables will be bigger and may possibly require a full page each. The choice of [hp] is because there is no limit on how many [p] floats can go on a page, but also want some on the first page of the section.

\documentclass{article}
\usepackage{siunitx}
\usepackage{subcaption}
\usepackage[colorlinks]{hyperref}

\DeclareCaptionLabelFormat{linked}{Subtable \ref{main}#2}

\begin{document}
\tableofcontents

\section{Table goes in main text}
\begin{table}[ht]
  \caption{Main Table}\label{main}
  \centering
  \begin{tabular}{cc}
    & See \ref{first}\\
    See \ref{second}&
  \end{tabular}
\end{table}

\clearpage
\appendix
\section[Subtables for Table \ref*{main}]{Subtables for Table \ref{main}}

\begingroup
  \renewcommand{\thetable}{\ref*{main}}%
  \renewcommand{\thesubtable}{.\arabic{subtable}}%
  \captionsetup[subtable]{labelformat=linked}%
  \setcounter{subtable}{0}% not automatic

\begin{table}[hp]
  \captionof{subtable}{}\label{first}
  \centering
  \begin{tabular}{S|S}
    {x} & {y}\\
    \hline
    1.0 & 3.2\\
    1.5 & 2.9
  \end{tabular}
\end{table}
\begin{table}[hp]
  \captionof{subtable}{}\label{second}
  \centering
  \begin{tabular}{S|S}
{x} & {y}\\
    \hline
    1.0 & 3.2\\
    1.5 & 2.9
  \end{tabular}
\end{table}
\endgroup% restore table subcaptions
\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • I was not able to get it to work with anchors. Also, pdfpages to merge pdf files is not an option as that does not retain links. – Peter Grill Sep 13 '19 at 16:37
  • @PeterGrill I do find it quite unclear what the question and your remarks is about. What is missing? The links in the question works fine for me. So what "improvement" is wanted? – Ulrike Fischer Sep 18 '19 at 07:34
  • @UlrikeFischer: Given the code in the question, does clicking on "Second" open the document to Page 2 (the "Second" table) for you? For me it opens to Page 1 (the "First" table). The answer puts everything into one pdf document, where as the question has the tables in a separate pdf document. – Peter Grill Sep 18 '19 at 14:34
  • @PeterGrill yes the code works fine for me. – Ulrike Fischer Sep 18 '19 at 14:39
  • Apologies for the confusion. The code posted in the question seems to work fine for me now -- not sure what happened earlier when clicking on second would open the first table. I think the solution in the question is much better than the answer. :-) I am awarding the bounty to this answer (although it is really for the code given in the question). – Peter Grill Sep 19 '19 at 04:31
  • Vielen dank! Now I can close it. – John Kormylo Sep 19 '19 at 04:35