'Attaching' Files to a Latex Document

  • LaTeX
  • Thread starter thegreenlaser
  • Start date
  • Tags
    files Latex
In summary, the conversation discusses the best way to include source code in a final report for easy access. Suggestions include using the attachfile package to attach the code to the Latex PDF, creating an appendix with the "listings" package, or hosting the code online and including a hyperlink. The attachfile package seems to be the most suitable option for the desired outcome.
  • #1
thegreenlaser
525
16
I'm writing a final report, and I've got a bunch of source code that I'd like to have readily available to anyone reading the document. I won't have any control over the files once I hand it in, so I'm a little wary about just putting everything in the same folder and trusting that everything will stay there. Is there any way that I can sort of 'attach' the source code to the Latex PDF so that if someone opens it up they can click a link and for sure be able to access these files, even if the only thing saved on the computer is that PDF?

Thanks.
 
Physics news on Phys.org
  • #3
jhae2.718 said:
Maybe create an appendix and use the "listings" package to format the source code?

Edit: it looks like there's an attachfile package: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.169.9317&rep=rep1&type=pdf http://www.ctan.org/tex-archive/macros/latex/contrib/attachfile

Another method would be to host the source online and include a hyperlink.

That attachfile package looks about perfect, assuming I can get it to work. I was going to just put all the source code in an appendix like you suggested, but I think there's too much for it to look nice. My intention is more for someone to be able to access the code and run it rather than necessarily study it closely.
 
Last edited by a moderator:

1. How do I attach files to a Latex document?

The most common way to attach files to a Latex document is by using the \includegraphics command. This command allows you to add images, diagrams, and other files to your document.

2. Can I attach multiple files to a Latex document?

Yes, you can attach multiple files to a Latex document by using the \includegraphics command multiple times, each with a different file name. Alternatively, you can use the \multiinclude command to attach multiple files at once.

3. What file formats can I attach to a Latex document?

Latex supports a variety of file formats for attachments, including PDF, PNG, JPEG, and EPS. However, it is recommended to convert your files to EPS format for the best compatibility with Latex.

4. How do I resize an attached file in my Latex document?

You can resize an attached file in your Latex document by using the \includegraphics command with the width or height parameters. For example, \includegraphics[width=0.5\textwidth]{image.png} will resize the image to 50% of the document's width.

5. Can I attach files to specific sections in my Latex document?

Yes, you can attach files to specific sections in your Latex document by using the \label and \ref commands. First, label the section using \label{sec:section1}, then refer to it in the \includegraphics command using \ref{sec:section1}. This will ensure the file is attached only to that specific section.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
9K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
Replies
15
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
7K
  • Programming and Computer Science
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
222
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
5K
Back
Top