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.
Best Answer
EDIT
... include a more sinister version...
I'm not sure if this is what you want. Strictly speaking, this file does not include itself. It includes its own output. This is what your images suggest you want but your description is ambiguous.
Anyway, since you mention using this with
bashful
, I thought I might as well usebashful
. This needs to be compiled with shell escape for obvious reasons. But, if you are usingbashful
, then you obviously have to compile in a way whichbashful
requires and will therefore be using shell escape anyway.A simple example:
A more sinister example using TiKZ: