1

I am using the svg package to include flag emojis as .svg files in my text with \includesvg{}. However, since I need to render a lot of flags which are the same, and each flag takes a lot of time, it hits the Overleaf compile time limit. Is there a way of optimising the rendering of repeats of the same .svg file, so that it doesn't time out? Unfortunately I can't use \emoji as the class file I am using requires pdflatex as a compiler.

\documentclass{article}

% SVG figures
\usepackage{svg}
\def\sweflag{\includesvg[width=1.5em]{flags/se}}

\begin{document}

Sweden is great! \sweflag\sweflag\sweflag\sweflag\sweflag\sweflag\sweflag\sweflag\sweflag

\end{document}

Download for Sweden flag .svg.

3
  • 1
    convert it once to pdf and then use \includegraphics. Sep 18 at 12:32
  • In case the exact shape of your image does not matter, you could use ctan.org/pkg/emoji Sep 18 at 14:07
  • @samcarter_is_at_topanswers.xyz I need to use pdflatex to conform with Elsevier template, otherwise I'd have used \emoji for sure Sep 18 at 19:05

1 Answer 1

2

Pkg xsavebox might be of help:

time pdflatex --shell-escape swedenXsbox.tex
...
real    0m0.551s
user    0m0.510s
sys 0m0.039s

swedenXsbox.tex:

\documentclass{article}

\usepackage{pgffor}

% SVG figures
\usepackage{svg}

\usepackage{xsavebox}
\xsbox{sweflag}{\includesvg[width=1.5em]{flags/se}}

\begin{document}

Sweden is great!
\foreach \i in {1,...,600} {\thesweflag\space}

\end{document}

whereas

time pdflatex --shell-escape swedenDef.tex
...
real    0m2.733s
user    0m2.598s
sys 0m0.119s

swedenDef.tex:

\documentclass{article}

\usepackage{pgffor}

% SVG figures
\usepackage{svg}
\def\sweflag{\includesvg[width=1.5em]{flags/se}}

\begin{document}

Sweden is great!
\foreach \i in {1,...,600} {\sweflag\space}

\end{document}

You must log in to answer this question.

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