[Tex/LaTex] Producing images for Twitter

conversionexportformattingmactexonline

I would like a way of producing high quality images optimised for sharing on Twitter. These images would likely contain a mixture of equations, text, tables, etc.

Ideally the output produced after compiling would:

  1. Produce an image in .png format;
  2. Be transparent (that is, have no background);
  3. Have a fixed width of 1024 pixels, and a maximum height of 1024;
  4. Contain reasonable margins, so the maths/text isn't right on the border.

Keeping in mind, Twitter shrinks images down to a width of 506 pixels when displayed in the timeline. If possible I would like to avoid using the command line.

So far what I have is:

\documentclass[preview]{standalone}
\usepackage{amsmath}
\usepackage{geometry}
\geometry{
paperwidth=506px,
paperheight=253px,
margin=0cm
}
\begin{document}
A \emph{group representation} is a group homomorphism
\[
    \rho \colon G \longrightarrow GL(V)
\]
from the group $G$ to the general linear group $GL(V)$. 
\end{document}

Best Answer

standalone works OK if you read the documentation.

\documentclass[border=10pt,preview,varwidth]{standalone}
\newenvironment{nothing}{}{}
\standaloneenv{nothing}
\begin{document}
\begin{nothing}
  A \emph{group representation} is a group homomorphism
  \[
  \rho \colon G \longrightarrow GL(V)
  \]
  from the group $G$ to the general linear group $GL(V)$.
\end{nothing}
\end{document}

cropped sample

You can then use standalone's conversion facilities to convert the pages on-the-fly to the format of your choice. The conversion may use either ImageMagick's convert utility or ghostscript. See the manual for details of how to configure this through standalone.

The chances are good that

\documentclass[border=10pt,preview,varwidth,png]{standalone}

or

\documentclass[border=10pt,preview,varwidth,convert]{standalone}

will do what you want, but you can fine-tune the process if required.

Here's the result I get with png:

transparent PNG

Related Question