0

is there any way where i can put a label on a full latex document and refer to it in another tex file.

e.g. supplement.tex

\documentclass[review,12pt]{article}
\usepackage{graphicx}
\begin{document}
\label{supplement1}


something

\end{document}

and in the main document main.tex do something like:

    \documentclass[review,12pt]{article}
    \usepackage{graphicx}
\externaldocument{supplement}
    \begin{document}


    something is refered from Supplement file~\ref{supplement1}

    \end{document}

EDIT

thanks for your comments, what i basically want is not to refer to a section or chapter in another document, but i want to refer to the whole document.

ifreak
  • 193
  • Check the answer here, I believe it does what you want. If not, please clarify by editing the question. – Paul Gessler Feb 12 '14 at 16:28
  • 1
    the latex cross reference mechanism to sections (including the xr system for external references) are designed to produce dynamically constructed numbers. For the file reference, if you just want the filename, just type the filename (or if you want it to be a link, hyperref can make it so) – David Carlisle Feb 12 '14 at 16:37
  • The "duplicate" question is answered by xr which does not answer this question. I voted for reopen. – David Carlisle Feb 12 '14 at 17:48

2 Answers2

4

Your question could be clearer (as seen from the comments and close/open votes) but I think you want

\documentclass[12pt]{article}
    \usepackage{hyperref}

    \begin{document}


    something is refered from Supplement file~\href{supplement1.pdf}{supplement1}

\end{document}

which makes the word supplement1 a link to supplement1.pdf

David Carlisle
  • 757,742
1

Solution 1

You can use the xr package to reference to other LaTeX document.

In the file supplementmain.tex you say:

\usepackage{xr}
\externaldocument{supplement}
...
\ref{ext:supplement}

Note: normally xr doesn't add hyperlinks. Use zref package for this. You only need to replace \externaldocument with \zexternaldocument.

Solution 2

A minimal working example taken from the following site: GUIT

First.tex

\documentclass[a4paper]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{xr-hyper} \usepackage{hyperref} \externaldocument[S-]{Second}[Second.pdf] \begin{document} \chapter{One}\label{chp:one} \chapter{Two}\label{chp:two} Bla Bla Bla. \end{document}

Second.tex

\documentclass[a4paper]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{xr-hyper} \usepackage{hyperref} \externaldocument[F-]{First}[First.pdf] \begin{document} \chapter{Beginning}\label{chp:One} Hello! \chapter{Continuation} I read chapters~\ref{F-chp:one}~and~\ref{F-chp:two} of the first file.

\end{document}

GUIT also says that in this way you have the hyperlink to the first file.

marchetto
  • 991