Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I try to embed a link to a local file in a LaTeX document via \href{file://./path-to-file}{filename} it's typeset as a remote link, so http:// is prepended. How can I link to a local file, with a path relative to the location of the PDF produced?

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

have you tried the \include{}command? Like \include{chapters/filename} you can include a .tex file. But don't write the .tex in the command. There is a page in the StackExchange network, which is only about TeX.

My base TeX project looks like this:

My projectname.tex

\input{header}
\begin{document}
\hyphenation{}          % Words where LaTex-hyphenation fails 
\maketitle          % Creates a page with the title
\newpage
%  \onehalfspacing              % This uses the package setspace
\tableofcontents        % This creates the table of contents
\include{chapter/acronym}   % Acronyms i use
\include{chapter/chapter_1}
% ...
\include{chapter/chapter_n}

\include{chapter/glossary}  % My glossary
\bibliography{bibliography/bibliography}  % Literature database
\end{document}

A chapter_x.tex looks like this:

\section[section short title]{section title}

And my header.tex looks like this:

%
% Document preamble
%
  \documentclass[  %
    12pt,          % default font size
    a4paper,       % papersize
    twoside,       % printout will be two sided
%    txt,           % 
    ]{article}

  \usepackage{ulem}          % all words have the underline at the same height \uline statt \underline

  \usepackage[     %
    T1             % T1 font has european sigs
    ]{fontenc}

  \usepackage[     %
    utf8           % Depends on the operating system
    ]{inputenc}    %

  \usepackage[     %
    dvips,         %
    usenames       % allows to use blue yellow etc for font colors
    ]{color}

  \usepackage{hyperref} % allows hyperlings in the table of contents

  \usepackage{amsmath} % math stuff
  \usepackage{amssymb}  % even more math stuff
  \usepackage{extpfeil}
  \usepackage[     % 
    style=long,   % 
%    toc=true,      % Boolean; if true the glossary will be shown in the table of contents
    hypertoc=true, % Hyperlinks in the glossary
    hyper=true,    % 
    number=none,   % 
    acronym=true   % 
    ]{glossary}
  \setacronymnamefmt{\gloshort}

  \usepackage{makeidx}
%  \usepackage{xymtexps}
%  \usepackage{cite} % Used for citing
  \usepackage{bibgerm}
  \usepackage[numbers,square]{natbib}
  \bibliographystyle{dinat}
  \usepackage{textcomp} % Allows to set a ° for example
  \usepackage[     % 
    german         % You may not need this *g*
    ]{babel}

  \usepackage{setspace} % allows to easily change the space between lines
  \usepackage{pstricks} % Used to create graphs
  \usepackage{pst-plot} % Used to create graphs

  \renewcommand{\acronymname}{Abkürzungsverzeichnis} % Sets the name for acronymepage (I'm from germany)
  \makeindex
  \makeacronym
  \makeglossary


  \author{Autor name}
  \title{Document title}
  \date{\copyright\ \today}

This setup works good for me.

Sorry for typos in the comments of the files. I just translated my comments from german and I'm too lazy to fix them g

share|improve this answer
    
@aresnick Try asking at tex.stackexchange.com –  Auron Feb 19 '11 at 23:57
    
Does this let me link to a file so that it could be opened with another program? I'm not looking to embed it--just provide a hyperlink to a file:/// url. –  aresnick Feb 20 '11 at 2:22
add comment

you should be able to put the URL in the \url tag:

\url{file://./path-to-file}

pdflatex will (I believe) do the right thing, so it appears as a link in the resulting PDF. Whether your computer will know how to open the file is another question.

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.