3

Looking for a solution to avoid arithmetic error while trying to get tikz and shapepar working together.

\documentclass{beamer}
\usepackage{tikz,shapepar}

\setbeamertemplate{title page}{%
\begin{tikzpicture}[remember picture,overlay]
%\node[circle,fill=black,text=white] {\shapepar{\circleshape} \inserttitle\par}; % <- not working
\end{tikzpicture}}

\title{Some title with variable length}
\begin{document}
\maketitle

\begin{frame}
\shapepar{\circleshape} \huge\inserttitle % <- working fine here
\end{frame}
\end{document}

According to David, this should be the syntax: \node[shape=circle,text width=0cm, fill=black,text=white] {\shapepar{\circleshape} \inserttitle\par};, with text width=0cm so that the node scales with the content. Anyhow, depending on the length of \inserttitle, I still encounter arithmetic overflow.

  • You can't specify 0pt: shapepar needs a target width for linebreaking? – David Carlisle Nov 16 '14 at 16:41
  • I guess it'll set the best linewidth by itself... – s__C Nov 16 '14 at 16:42
6

a node is an \hbox and can't have paragraph things unless you specify either text width or align=<...> keys (when it becomes a minipage environment)

\documentclass{beamer}
\usepackage{tikz,shapepar}

\setbeamertemplate{title page}{%
\begin{tikzpicture}[remember picture,overlay]
\node[text width=6cm, fill=black,text=white] {\shapepar{\circleshape} \inserttitle\par}; % <- not working
\end{tikzpicture}}

\title{Some title with variable length}
\begin{document}
\maketitle

\begin{frame}
\shapepar{\circleshape} \huge\inserttitle % <- working fine here
\end{frame}
\end{document}

or a version with a long title and the division operator modified so it never overflows (just returns \maxdimen

enter image description here

\documentclass{beamer}
\usepackage{tikz,shapepar}
\makeatletter
\def\fpdivide#1#2{%
\@tempcntb #2\relax
\multiply\@tempcntb10
#1=\dimexpr(#1*\p@ /\@tempcntb) \relax
\ifdim#1>0.1\maxdimen
#1=\maxdimen
\else
\multiply#1 by 10
\fi
}

\makeatother

\setbeamertemplate{title page}{%
\begin{tikzpicture}[remember picture,overlay]
\node[text width=8cm, fill=black,text=white] {\shapepar{\circleshape} \inserttitle\par}; % <- not working
\end{tikzpicture}}

\title{Some title with variable length
x x x x x x x x x x x
very very long
very very long
very very long
very very long
very very long
}
\begin{document}


\maketitle

\begin{frame}
\shapepar{\circleshape} \huge\inserttitle % <- working fine here
\end{frame}
\end{document}
  • What about the arithmetic overflow? (\fpdivide ...1=\dimexpr #1*\p@ /\@tempcntb \relax) – s__C Nov 16 '14 at 16:34
  • @s__C I got no overflow on the document as posted (texlive 2014) what versions are you using? – David Carlisle Nov 16 '14 at 16:40
  • MacTeX 2014 here. Have you tried increasing the length of \title? – s__C Nov 16 '14 at 16:40
  • @s__C the question is supposed to provide an example that demonstrates the problem:-) I'll add some words.... – David Carlisle Nov 16 '14 at 16:42
  • Like this: "Some title with variable length all across the titlepage even with a very long title"... – s__C Nov 16 '14 at 16:43

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.