title: How to do a link to a file in rst with sphinx and get pdf output?
body: <p>In rst and sphinx, I want to link to an external pdf file <strong>after I have created pdf output</strong>. I understand that I have to use the <code>:download:</code> directive, e.g.</p>
  
  <pre><code>here is a pdf file :download:`pdf &lt;doc/mypdf.pdf&gt;`
  </code></pre>
  
  <p>While this <strong>works fine generating html output</strong>, it does not work for pdfs generated from sphinx (using <code>make pdf</code> or <code>make latexpdf</code>). 'Does not work' means that while the links are shown, the document does not open if I click on the link. It only opens for html links in the document.</p>
  
  <p>I am aware of the question and answer:
  <a href="https://stackoverflow.com/questions/14345922/how-to-do-a-link-to-a-file-in-rst-with-sphinx">How to do a link to a file in rst with sphinx?</a>  ,</p>
  
  <p>but this does not help me, since this only covers html output.</p>
  
  <p>While I am not sure about rst2pdf, at least Latex should contain directives which allow to include links to pdfs which can be clicked on, e.g. hyperref as described here: <a href="https://tex.stackexchange.com/questions/41539/does-hyperref-work-between-two-files/41605#41605">https://tex.stackexchange.com/questions/41539/does-hyperref-work-between-two-files/41605#41605</a></p>
  
  <p>Any ideas? Is this possible at all?</p>
  
  <p><br>
  <strong>EDIT:</strong>
  With `make latexpdf, links to pdfs such as</p>
  
  <pre><code>:download:`PDF-document &lt;filename.pdf&gt;`
  </code></pre>
  
  <p>get translated into latex as </p>
  
  <pre><code>\sphinxcode{PDF-document}
  </code></pre>
  
  <p><code>\sphinxcode</code> seems to refer to some kind of latex macro, but even with the newest version of Tex live installed, this macro does not get resolved in a way that links would be clickable. Furthermore, the link itself (<code>PDF-document</code>) is already lost in the latex document.</p>
  
  <p><br>
  <strong>EDIT 2:</strong></p>
  
  <p>A file sphinx.sty gets created by <code>make pdflatex</code> which defines the commands <code>\sphinxincludegraphics</code> (for including images, where the links work) and <code>\sphinxcode</code> (for including pdfs,where the link does not work). I am adding a latex tag to this post, maybe someone there can help to understand the problem.</p>