8

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

5
  • 3
    To close voters: the previous question of OP gave a pretty good result: tex.stackexchange.com/questions/68517/… Aug 6, 2016 at 1:27
  • 2
    @PrzemysławScherwentke: Words like "more fancy" is subjective or "primarily opinion-based.
    – Werner
    Aug 6, 2016 at 2:18
  • 3
    How about adding more informations, like what for a tweet (example) and how should it be displayed? Your question is very, very unclear!
    – Mensch
    Aug 6, 2016 at 18:58
  • I'd like to see an answer!
    – JPi
    Aug 6, 2016 at 21:21
  • 1
    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

1 Answer 1

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:

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .