How do I include binary data (e.g. the contents of a binary file) in a LaTeX generated PDF-document? If I just copy and paste them into a verbatim environment it results in garbage.
Asked
Active
Viewed 2,578 times
6
2 Answers
15
Normally people use a utility such as hexdump to view the content of binary files. It could be used to pre-format data for LaTeX, too:
\documentclass{article}
\usepackage{verbatim}
\begin{document}
\scriptsize % Just so that it fits in line
\verbatiminput{dump.txt} % Generated with "hexdump -C" on Linux
\end{document}
The result:

EDIT: It turns out there's a LaTeX package hexdump. But it more or less does the same thing as above, the most notable addition being floating dumps with captions.
Andrey Vihrov
- 22,325
-
4"floating dumps with captions" ... the mental image that that phrase creates will stay with me for a looong time. – Andrew Stacey May 16 '11 at 08:29
-
2
You can use the attachfile package. Abstract:
This package defines an
\attachfilecommand that lets you attach arbitrary files to a pdf document. These files are embedded right in the pdf file, so they get transmitted along with it. The package also gives you control over the corresponding icon's properties and various other associated metadata.
Paul Gaborit
- 70,770
- 10
- 176
- 283
\7 V??#?:-)– Matthew Leingang May 15 '11 at 11:44<e8>(wheree8is the hexadecimal number of the byte). You would need to this conversion by yourself. – Martin Scharrer May 15 '11 at 11:49