So, I have a couple of questions, I'll try to build it up progressively:
I want to use labels and references for words or phrases instead of the usual reference to a section number or page. I found a solution here - Heiko's solution - that works for me, so I can then use
\LBL[A-01]{some phrase}and when I want to print out "some phrase" I use
\ref{A-01}which works great. So far so good, but if anyone has any other ideas - especially in light of what follows, I would be happy to hear them.
Then I want to be able to use this system between files. So in one file I have a list of all the phrases (which might change at some point) and in another file I can just use
\refto get the phrases from the other file. I found simply adding\usepackage{xr}and the appropriate\externaldocument{}command, that worked fine in conjunction with the\LBLcode from above.Now this is where it got too tricky for me. I want the 'some phrase' to actually be a url or rather href. So to get urls in the first place, I add the
hyperrefpackage, and then it seems thexrpackage gets all weird, which is fixed by usingxr-hyperinstead. So I want the 'some phrase' to be the description of the href from the other file, AND I want clicking on it to take me to the url, and NOT to the other pdf.
Maybe this is too involved of an explanation, so I've got a minimal working example below - you have to name them file1.tex and file2.tex:
file1.tex
\documentclass[12pt]{article}
\usepackage{xr-hyper}
\usepackage{hyperref}
\externaldocument{file2}
\newcounter{word}
\makeatletter
\newcommand*{\LBL}{%
\@dblarg\@LBL
}
\def\@LBL[#1]#2{%
\begingroup
\renewcommand*{\theword}{#2}%
\refstepcounter{word}%
\label{#1}%
#2%
\endgroup
}
\makeatother
\begin{document}
\ref{A-01}
\ref{A-02}
\end{document}
file2.tex:
\documentclass[12pt]{article}
\usepackage{xr-hyper}
\usepackage{hyperref}
\externaldocument{file1}
\newcounter{word}
\makeatletter
\newcommand*{\LBL}{%
\@dblarg\@LBL
}
\def\@LBL[#1]#2{%
\begingroup
\renewcommand*{\theword}{#2}%
\refstepcounter{word}%
\label{#1}%
#2%
\endgroup
}
\makeatother
\begin{document}
\LBL[A-01]{some phrase}
\LBL[A-02]{\href{https://tex.stackexchange.com/}{Best website ever}}
\end{document}
What happens now is that in file1.pdf both lines are hyperlinks to file2.pdf. But I want the first one to not be a clickable link at all, just normal text, and the second one to be the url hyperlink. I hope this makes sense.. How should I go about doing such a thing?