# Quoting tweets inside a LaTeX document?

Is there a package to typeset tweets in a more fancy way than simply quoting?

• To close voters: the previous question of OP gave a pretty good result: tex.stackexchange.com/questions/68517/… Aug 6, 2016 at 1:27
• @PrzemysławScherwentke: Words like "more fancy" is subjective or "primarily opinion-based.
– Werner
Aug 6, 2016 at 2:18
• How about adding more informations, like what for a tweet (example) and how should it be displayed? Your question is very, very unclear! Aug 6, 2016 at 18:58
• I'd like to see an answer!
– JPi
Aug 6, 2016 at 21:21
• So I was experimenting with this because of this question. This is just simple quote but automated! curl 'https://publish.twitter.com/oembed?url=https://twitter.com/Interior/status/463440424141459456' |perl -MJSON -pe 'BEGIN { binmode STDOUT, ":utf8"; } $_ = decode_json$_; $_ =$_->{html}' | pandoc -f html -t latex --latex-engine=xelatex -o tweet.pdf
– wilx
Aug 6, 2016 at 22:55

So I bit the bait and done something: tweet2latex. This is a utility based on twarc that retrieves tweets and necessary images and generates LaTeX fragment to standard output. Run this from command line, e.g., like this:

./tweet2latex.py 762602474293321728 |tee tweet.tex


The tweet.tex file will contain something like this:

\begin{tweet}\tweetUserImage{https://pbs.twimg.com/profile\_images/683232086958993408/rnyugqzL\_normal.jpg}{rnyugqzL-normal.jpg}{701158958}\tweetUserName{701158958}{MedicNow}It could be worse. You could be the lifeguard at the \tweetHashtag{Rio}{\#Rio} swimming pool.... \tweetHashtag{MondayMotivation}{\#MondayMotivation} \tweetPhoto{http://twitter.com/MedicNow/status/762602474293321728/photo/1}{https://pbs.twimg.com/media/CpVOzW7WEAAhMte.jpg}{CpVOzW7WEAAhMte.jpg}{https://t.co/AfoOoV9qQw}\tweetItself{762602474293321728}{Mon Aug 08 10:52:52 +0000 2016}\end{tweet}


This can be then included in your LaTeX document with \input{tweet}. For this to render into something you will have to define tweet environment and some command in it. See example document tweet-document.tex for complete file, here is just the tweet environment:

\newenvironment{tweet}{%
\newcommand{\tweetUserImage}[3]{%
\begingroup%
\includegraphics[keepaspectratio,height=1em]{##2}%
\endgroup
}%