5

This is what I'm trying to produce:

Image

This is what I have so far:

\documentclass[varwidth,12pt,preview,margin=3mm]{standalone}

\usepackage{newtxtext}
\usepackage{newtxmath}
\usepackage{color}
\pagecolor{yellow}

\begin{document}

\begin{center}
Animation Test
\vspace{6pt}

\textbf{\huge 1}
\end{center}

\end{document}

I can't get the background colour to work, but it otherwise looks more or less as it should. I've tried other document classes but they all have their own problems, such as adding in a ton of extra features I don't want, or else other parts of the code don't work instead.

Could someone help me get it working?

  • I am not sure why it doesn't work with standalone class, however, it does run okay with article class (of course, without adding any extra packages). May be something for you to check at: tex.stackexchange.com/questions/25137/…; tex.stackexchange.com/questions/82498/… – Raaja Nov 5 '18 at 8:13
  • 2
    try removing the preview mode :) as if in \documentclass[varwidth,12pt,margin=3mm]{standalone}. May be that could help. – Raaja Nov 5 '18 at 8:17
  • Thanks @Raaja. Removing preview worked. The documentation for standalone seemed to suggest I needed that to get the margins working correctly, but apparently not. Seems to be all fine now. :) – Ulysses Nov 5 '18 at 8:25
  • 1
    It's either preview or varwidth to get paragraph mode for the content. Using both might not do what you want. – Martin Scharrer Dec 21 '18 at 9:09
  • 1
    @Raaja: Please post your comment as an answer then, so the OP can accept it. This concludes the question officially and removes it from the "unanswered list". – Martin Scharrer Dec 26 '18 at 17:53
5

Removing the preview mode as in \documentclass[varwidth,12pt,margin=3mm]{standalone} should do the job. Whence, you could use this:

\documentclass[varwidth,12pt,margin=3mm]{standalone}

\usepackage{newtxtext}
\usepackage{newtxmath}
\usepackage{color}
\pagecolor{yellow}

\begin{document}

\begin{center}
Animation Test
\vspace{6pt}

\textbf{\huge 1}
\end{center}

\end{document}
5

You can do this very easily using standalone and adjustbox. Use the stack key to stack the text and number, the margin key for the margin and the bgcolor key for the background color. The \struts are for the correct lineskip.

\documentclass[12pt]{standalone}

\usepackage{newtxtext}
\usepackage{newtxmath}
\usepackage{xcolor}
\usepackage{adjustbox}

\begin{document}
\adjustbox{stack,margin=3mm,bgcolor=yellow}{%
    Animation Test\strut\\[6pt]
    \huge\bfseries 1\strut}%
\end{document}

enter image description here


With this solution you could also add an animation with different background colors:

\documentclass[12pt,multi=PAGE]{standalone}

\usepackage{newtxtext}
\usepackage{newtxmath}
\usepackage{xcolor}
\usepackage{adjustbox}
\usepackage{tikz}
\begin{document}
\foreach \n in {1,...,10} {%
\begin{PAGE}%
\adjustbox{stack,margin=3mm,bgcolor=yellow!\the\numexpr10*\n\relax}{%
    Animation Test\strut\\[6pt]
    \huge\bfseries \n\strut}%
\end{PAGE}%
}%  
\end{document}

enter image description here

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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