Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This question already has an answer here:

Under the assumption that my machine is connected to the Internet, how can I automatically include my TeX.SE flair in my output document at compile time?

enter image description here

My understanding is that an SE flair is just a .png generated server-side when queried; at least, that's what I gather from the HTML code on my flair page.

Note that I want the process to be automated; I do not want to "manually" download the flair and then "manually" include it with \includegraphics.

Therefore, the problem reduces to including an image from the Web, as in Can I use an image located on the web in a LaTeX document?.

However, I cannot get that solution to work for my flair. I use the following command (in TeXmaker 4.0.1, with TeXlive, on Mac OS 10.8.3):

"/usr/texbin/pdflatex" -synctex=1 --shell-escape -interaction=nonstopmode %.tex

Here is my code:

\documentclass{article}
\usepackage{graphicx} 
\begin{document}
\write18{wget http://tex.stackexchange.com/users/flair/21891.png}
\includegraphics{21891.png}
\end{document}

and here is my output:

enter image description here

Subsidiary question: I haven't researched this very much, but is there an easy way to produce a pdf that will automatically query SE servers for an up-to-date flair? I'm guessing this would probably involve some Javascript (which the pdf reader should enable), as in How can I typeset the date/time at compile time?, but I'm not sure how to do it.

share|improve this question

marked as duplicate by Jubobs, Werner, doncherry, cgnieder, Guido Apr 22 '13 at 20:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
Everything works fine here. I'm using Lubuntu 11.10 with TeX live 2011. –  Sigur Apr 22 '13 at 13:44
2  
@Jubobs: take a look at tex.stackexchange.com/questions/88430/… –  Papiro Apr 22 '13 at 14:22
2  
When I try it it works the second time (making wgert fetch it again to a renamed _ version. I assume there is a timing issue that the file is not available for reading quick enough due to the buffering somewhere. Simpler just to run wget before pdflatex:-) –  David Carlisle Apr 22 '13 at 14:48
1  
may be @Papiro should make an answer to gain weight if he is interested –  texenthusiast Apr 22 '13 at 14:48
    
@Papiro As texenthusiast wrote, feel free to post your own answer, and I'll delete mine. –  Jubobs Apr 22 '13 at 15:01

1 Answer 1

up vote 2 down vote accepted

This solution worked for me (with -shell-escape enabled).

Thanks to @Papiro for his link!

Of course, you'll have to substitute your user number for mine, if you want to include your own flair :)

\documentclass{article}
\usepackage{graphicx}
\newcommand*{\grabto}[1]{%
    \IfFileExists{#1.png}{}{%
        \immediate\write18{%
            curl \detokenize{http://tex.stackexchange.com/users/flair/}#1.png -o #1.png%
        }%
    }%
}

\grabto{21891}
\begin{document}
    \includegraphics{21891.png}
\end{document}
share|improve this answer
    
Does that make this question a duplicate? –  doncherry Apr 22 '13 at 18:58
    
Yes, I suppose, although my subsidiary question remains open. –  Jubobs Apr 22 '13 at 19:28
    
@Jubos Your subsidiary question is about a pdf with an image that updates after compiling, if I understand correctly? I guess the cleanest way of handling this we close this question as a duplicate and you ask the subsidiary question as a follow-up question. –  doncherry Apr 22 '13 at 20:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.