Is there a package to typeset tweets in a more fancy way than simply quoting?
Asked
Active
Viewed 2,116 times
8
1 Answers
18
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}%
\quad
\endgroup
}%
\newcommand{\tweetUserName}[2]{\href{https://twitter.com/intent/user?user_id=##1}{##2}\\}%
\newcommand{\tweetHashtag}[2]{\href{https://twitter.com/hashtag/##1}{##2}}%
\newcommand{\tweetUserMention}[2]{\href{https://twitter.com/intent/user?user_id=##1}{##2}}%
\newcommand{\tweetUrl}[4]{\href{##2}{##3}}%
\newcommand{\tweetPhoto}[4]{\\\includegraphics[keepaspectratio]{##3}\\}%
\newcommand{\tweetItself}[2]{\flushright \href{https://twitter.com/statuses/##1}{##2}}%
\begin{tcolorbox}[size=small,nobeforeafter]%
\RaggedRight%
}{\end{tcolorbox}}
See complete PDF with few tweets, here is just one page:
wilx
- 2,339

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 06 '16 at 22:55