1

I have a cross referencing problem using the standalone class. Let me clarify. This is the Main.tex:

    %** Main.tex**

\documentclass{article}
\usepackage[italian]{babel} 
\usepackage{amsmath,amssymb,amsthm}  
\usepackage{hyperref} 
\usepackage{graphicx}
\usepackage{xcolor}  
\usepackage{pgfplots}   
 \usepackage{standalone}
\usepackage{tikz}
\usetikzlibrary{spy}
\usetikzlibrary{decorations.fractals}
\usetikzlibrary{external}       
    \tikzexternalize

\newtheorem{theorem}{Theorem}
%*********************************************************************************
% Impostazioni di hyperref
%*********************************************************************************
\hypersetup{%
    hyperfootnotes=true,pdfpagelabels, 
    colorlinks=true, linktocpage=true, pdfstartpage=1, pdfstartview=FitV, 
    breaklinks=true, pdfpagemode=UseNone, pageanchor=true, pdfpagemode=UseOutlines,%
    plainpages=false, bookmarksnumbered, bookmarksopen=true, bookmarksopenlevel=1,%
    hypertexnames=true, pdfhighlight=/O,
    urlcolor=blue, linkcolor=blue, citecolor=webgreen,
    pdfsubject={},%
    pdfkeywords={},%
    pdfcreator={pdfLaTeX}
}

\begin{document}

We consider the following equation 
\begin{equation}
\label{eqn:a=b}
A=B\,\,.
\end{equation}
In reference to the eq.\,\eqref{eqn:a=b}, we consider the table~\ref{tab:AB}.\\

\tikzset{external/remake next=true}
\begin{table}
 \hspace{-1cm}\includegraphics[width=1.2\textwidth]{DisgnRq}
\caption{A vs B}
\label{tab:AB}
\end{table}
Lorem ipsum ...
\begin{theorem}
\label{thm:L}
Dolor sit amet...
\end{theorem}

From the Theorem~\ref{thm:L}, we obtain...
\end{document}

and this is the DisgnRq.tex :

    %** DisgnRq.tex**

\documentclass[%
border={1cm .5cm 2cm .5cm} % left bottom right top
]{standalone}
\usepackage{amsmath,amssymb,amsthm}  
\usepackage{hyperref} 
\usepackage{xcolor}                     
\usepackage{tikz}
\usepackage{preview}
\hypersetup{%
    hyperfootnotes=true,pdfpagelabels, 
    colorlinks=true, linktocpage=true, pdfstartpage=1, pdfstartview=FitV, 
    breaklinks=true, pdfpagemode=UseNone, pageanchor=true, pdfpagemode=UseOutlines,%
    plainpages=false, bookmarksnumbered, bookmarksopen=true, bookmarksopenlevel=1,%
    hypertexnames=true, pdfhighlight=/O,
    urlcolor=blue, linkcolor=blue, citecolor=webgreen,
    pdfsubject={},%
    pdfkeywords={},%
    pdfcreator={pdfLaTeX}
}
\PreviewEnvironment{tikzpicture}
\usetikzlibrary[positioning]
\usetikzlibrary{patterns}

\tikzset{S1/.style  = {draw, text centered,
                        minimum height = 1.5cm,
                        minimum width  = 13em,
                        fill = green!15
}}
\tikzset{S2/.style = {draw, text centered,
                         minimum height = 1.5cm,
                         minimum width = 8em,
                         fill           = yellow!30,
                         text width = 12.35 em
}}


\begin{document}

\begin{center}
\begin{tikzpicture}[node distance=0 cm,outer sep = 0pt]

\node[S1,minimum height = 1cm] (A) at (-7,5.5) {A};

\node[S2,minimum height = 1cm] (B) [right=of A]   {B};

% A
\node[S1] (A1) [below=of A] {A1 (cfr.\,eq.\,\eqref{eqn:a=b})};

% B
\node[S2] (B1) [below=of B] {B1\\ \vspace{.2em}\fontsize{7.5}{5}\selectfont{Lorem ipsum (vd.\,Teorema~\ref{thm:L})}};

\end{tikzpicture}
\end{center}

\end{document}

As you can see, the relative references are not compiled: Compilation

Any suggestions?

  • Your file using the standalone class is not compilable, and most likely, you need \usepackage{xr} and \externaldocument[dis::]{DisgnRq} in the preamble of your external file, referencing must be replaced with \eqref{dis::eqn:a=b}`. – user31729 Jan 27 at 13:38
1

Thanks for the hint, Christian Hupfer!

I changed in this way "DisgnRq.tex" :

%** DisgnRq.tex**

\documentclass[%
border={1cm .5cm 2cm .5cm} % left bottom right top
]{standalone}
\usepackage{amsmath,amssymb,amsthm} 
\usepackage{xr-hyper} % *suggested change*
\usepackage{hyperref}
\usepackage{xcolor}             
\usepackage{tikz}
\usepackage{preview}
\hypersetup{%
    hyperfootnotes=true,pdfpagelabels, 
    colorlinks=true, linktocpage=true, pdfstartpage=1, pdfstartview=FitV, 
    breaklinks=true, pdfpagemode=UseNone, pageanchor=true, pdfpagemode=UseOutlines,%
    plainpages=false, bookmarksnumbered, bookmarksopen=true, bookmarksopenlevel=1,%
    hypertexnames=true, pdfhighlight=/O,
    urlcolor=blue, linkcolor=blue, citecolor=webgreen,
    pdfsubject={},%
    pdfkeywords={},%
    pdfcreator={pdfLaTeX},%
    pdfproducer={LaTeX with hyperref and ClassicThesis}%
}
\PreviewEnvironment{tikzpicture}
\usetikzlibrary[positioning]
\usetikzlibrary{patterns}

\tikzset{S1/.style  = {draw, text centered,
                        minimum height = 1.5cm,
                        minimum width  = 13em,
                        fill = green!15
}}
\tikzset{S2/.style = {draw, text centered,
                         minimum height = 1.5cm,
                         minimum width = 8em,
                         fill           = yellow!30,
                         text width = 12.35 em
}}
\externaldocument[main::]{Main} % *suggested change*

\begin{document}

\begin{center}
\begin{tikzpicture}[node distance=0 cm,outer sep = 0pt]

\node[S1,minimum height = 1cm] (A) at (-7,5.5) {A};

\node[S2,minimum height = 1cm] (B) [right=of A]   {B};

% A
\node[S1] (A1) [below=of A] {A1 (cfr.\,eq.\,\eqref{main::eqn:a=b})};



% B
\node[S2] (B1) [below=of B] {B1\\ \vspace{.2em}\fontsize{7.5}{5}\selectfont{Lorem ipsum (vd.\,Teorema~\ref{main::thm:L})}};

\end{tikzpicture}
\end{center}

\end{document}

and indeed it works!

However the problem is almost solved: the only problem that has remained is that while the references in the body of the text are "active links", those in the table are not.

Any ideas?

P.S. I use TeXLive-2011 that's why you're having trouble compiling "DisgnRq.tex".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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