Clarification: The question may be related to the the quine fun question, but IMHO it is quite distinct.
The question here to write an "ouroboros" in TeX, i.e., a file that includes itself as a figure. In other words, the output should include in it a figure which presents the figure. In a sense, this is like a fractal, since the figure would show a the entire document, which hopefully is only one page. Now, in this figure, you would see a scaled down image of the output, which would have in it a figure.
In other words, the "ouroboros" is not a "quinn", but rather something like this image:
or this one:
Here is my attempt to do that:
\documentclass[twocolumn,10pt]{article}
\usepackage{pdfpages}
\usepackage{lipsum}
\title{The Ouroboros}
\author{U. Roboros}
\begin{document}
\maketitle
\lipsum[1]
\par
\begin{figure}
\includepdf[frame,scale=0.4]{ouroboros.pdf} %
\end{figure}
\par
\lipsum[3]
\par
\lipsum[2]
\end{document}
The idea is that in each run of the file through LaTeX, it would present an image, which is included as a figure in the next run.
This can be thought of as an amusing exercise, but a solution could be useful in writing documentation for TeX files; the idea being that you generate a LaTeX file,
e.g, using bashful
, compile it, and then include it as a figure.
The above solution cannot work, since the moment you run latex, the previous PDF file is erased. Perhaps a solution would be to have two files, each including the other. Another option is to copy the input into a temporary file, compile it, and then include it.
Another issue with the above is that pdfpags seems, at least for me, to be in conflict with the figure environment.
Note that the some of the answers to Self-replicating (La)TeX document do similar things, let the file include itself in some sense. Here, this should be done at the rendered level, rather than on textual basis.
\includepdf[]{}
starts a new page.figure
cannot include a page break. So, yes, they are incompatible. And essentially so. You'd need\includegraphics[]{}
instead...\let\newpage=\relax
before the\includepdf
kills the new page (best be inside a group at that point).\includepdf
easier when I want a full page inclusion, ie I want the PDF page as the background to the current page, possibly for further annotation. With\includegraphics
then TeX complains if the graphic is larger than the available text space on the page.=
.\let\a\b
and\let\a=\b
are the same. I find the second easier to see at a glance what it's doing so tend to put the equals sign in place. I understand that in the Good Old Days, tokens were precious and so the=
was frowned upon. Nowadays, we're gluttonous about tokens so the difference is in the mind of the beholder.