2

I am using this template (kik-android.cls, now whatsapp.cls):

Showcase of beautiful typography done in TeX & friends

as a guide to write a document using pdflatex mode. Since I am on pdflatex I deleted \usepackage{fontspec} and \setmainfont{DroidSans}.

Now I want to change the dimensions of the document since I have to print it on a A4 paper. So I change the line:

\usepackage[top=.55in,bottom=.55in,right=.015in,left=.015in,paperwidth=2.308in,paperheight=4.103in]{geometry}

to

\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}

and a lot of errors appeared.

With errors

In chat some users kindly told me that a change from a small size to a large paper size may cause problems with tikzpicture.

This is whatsapp.cls:

% whatsapp.cls
%   taken from https://tex.stackexchange.com/questions/1319/showcase-of-beautiful-typography-done-in-tex-friends/239511#239511
%   by Brian Jacobs (fixes by Maximilian Noethe).
%   April 10, 2018
%

\ProvidesClass{whatsapp}

% Start with article. Eventually this should be removed,
% because I'm not actually using it for much of anything
\LoadClass{article}

% Load all necessary packages
\usepackage{varwidth}
%\usepackage{fontspec}
%\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{calc}


% Set up the page
%\usepackage[top=.55in,bottom=.55in,right=.015in,left=.015in,paperwidth=2.308in,paperheight=4.103in]{geometry}
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}

% Style the page
\pagestyle{empty}
%\setmainfont{DroidSans}
\setlength{\parindent}{0pt}

% Color Definitions
\usepackage{xcolor}
\definecolor{backgroundgray}{RGB}{238,238,238}
\definecolor{linegray}{RGB}{212,212,212}
\definecolor{circgray}{RGB}{199,199,199}
\definecolor{circdarkgray}{RGB}{117,117,117}
\definecolor{arrowgray}{RGB}{107,107,107}
\definecolor{msggreen}{RGB}{185,224,97}
\definecolor{androidgray}{RGB}{191,191,191}
\definecolor{repwiregreen}{RGB}{71,146,53}
\definecolor{kikblue}{RGB}{103,142,233}
\definecolor{kiktimepalegray}{RGB}{158,169,184}
\definecolor{kiktimedarkgray}{RGB}{122,133,151}

% Customization Flags
\def\@hours{12}
\def\@minutes{11}
\def\@partnerName{Sample Name}

% Macros to draw the background
\def\@statusbar#1{%
  \def\c{androidgray}
  \fill[\c]
    let \p1 = (current page.north east) in
      (\x1 - .42in - #1in, \y1 - 0.0415in - #1in) rectangle (\x1 - .43in -#1in, \y1 - 0.1409 in);
}

% Background Macro
\def\@drawBackground{
  \begin{tikzpicture}[remember picture, overlay]
    % Background
    \fill[backgroundgray] (current page.north east) rectangle (current page.south west);

    \fill[black]
    (current page.south west) -- (current page.south east) --++(0,1in) -| (current page.south west) -- cycle;
    \fill[green]
    let \p1 = (current page.north east) in
    let \p2 = (current page.north west) in
    (\p1,\y1 - 0.1667in) rectangle (\x2,\y2 - .5289in);
    \fill[white]
    let \p1 = (current page.south east) in
    let \p2 = (current page.south west) in
    (\x1,\y1 + 0.3141in) rectangle (\x2,\y2 + .6090in);
    \draw[thick,linegray]
    let \p1 = (current page.south east) in
    let \p2 = (current page.south west) in
    (\x1,\y1 + .6090in) -- (\x2,\y2 + .6090in);

    % Kik Top bar decorations

      % Name
    \draw
      let \p1 = (current page.north west) in
        (\x1 + .4647in, \y1 - .3481in) node[anchor=west] {\@partnerName};

      % Arrow
    \draw[thick,circdarkgray]
      let \p1 = (current page.north west) in
        (\x1 + .1314in, \y1 - .3397in) -- (\x1 + .2179in , \y1 - .3397in);
    \draw[thick,circdarkgray]
      let \p1 = (current page.north west) in
        (\x1 + .1795in, \y1 - .2981in) -- (\x1 + .1314in, \y1 - .3397in) --
        (\x1 + .1795in, \y1 - .3846in);

    % Kik Bottom Bar Decorations

    % Android Bottom Bar Decorations
    % Home
    \draw[very thick,androidgray]
      let \p1 = (current page.south) in
        (\x1 - .1186in, \y1 + .08974in) -- (\x1 + .1186in, \y1 + .08974in) -- 
        (\x1 + .1186in, \y1 + .1795in)  -- (\x1, \y1 + .2115in) -- 
        (\x1 - .1186in, \y1 + .1795in) -- cycle;

    % Pages
    \draw[very thick,androidgray]
      let \p1 = (current page.south east) in
        (\x1 - .4391in, \y1 + .1058in) rectangle (\x1 - .6026in, \y1 + .1795in);
    \draw[very thick,androidgray]
      let \p1 = (current page.south east) in
        (\x1 - .3974in, \y1 + .1346in) -- (\x1 - .3974in, \y1 + .2219in) --
        (\x1 - .5545in, \y1 + .2219in);

    % Back arrow
    \draw[very thick,androidgray]
      let \p1 = (current page.south west) in
        (\x1 + .4199in, \y1 + 0.1635in) -- (\x1 + .5833in, \y1 + 0.1635in) to[bend left=90]
        (\x1 + .5833in, \y1 + .0993in) -- (\x1 + .5032in, \y1 + .0993in);
    \draw[very thick,androidgray]
      let \p1 = (current page.south west) in
        (\x1 + .4487in, \y1 + .1987in) -- (\x1 + .4199in, \y1 + .1635in) -- (\x1 + .4487in, \y1 + .1282in);

  \end{tikzpicture}
}

% Make the background appear on every page
\usepackage{everypage}
\AddEverypageHook{\@drawBackground}


% Commands for use by the user.
\def\setPartnerName#1{
  \def\@partnerName{#1}
}

\def\setPartnerPic#1{
  \def\@partnerPic{#1}
}

\def\setHours#1{
  \def\@hours{#1}
}

\def\setMinutes#1{
  \def\@minutes{#1}
}

\def\me#1{
  \hphantom{.}\hfill\begin{tikzpicture}
    \draw (0,0) node[anchor=north east,rectangle,rounded corners=2,fill=msggreen, scale=0.75,draw=circgray] {
      \hspace{.1in}\begin{varwidth}{1.5in}
        \vphantom{.}
        \raggedright #1\\
        \tiny \color{msggreen}.
      \end{varwidth}
      \hspace{.1in}%
    };
    \fill[msggreen] (-0.01in,-0.06in) -- (0.06in,-0.12in) -- (-0.01in,-0.18in) -- cycle;
    \draw[circgray] (0,-0.06in) -- (0.06in,-0.12in) -- (0in,-0.18in);
  \end{tikzpicture}
  \vspace{.05in}\\
}

\def\you#1{
  \begin{tikzpicture}
    \ifdefined\@partnerPic
    \draw (-.6,-.3) node[scale=1.825,circle, path picture={
        \node at (path picture bounding box.center){
          \includegraphics[width=.24in]{\@partnerPic}
        };
      }
    ] {};
    \else\fill[black] (-.6,-.3) circle (.12in);\fi
    \draw (0,0) node[anchor=north west,rectangle,rounded corners=2,fill=white, scale=0.75,draw=linegray] {
      \hspace{.1in}\begin{varwidth}[c]{1.5in}
        \vphantom{.}
        \raggedright #1\\
        \tiny \color{white}.
      \end{varwidth}
      \hspace{.1in}
    };
    \fill[white] (0.01in,-0.06in) -- (-0.06in,-0.12in) -- (0.01in,-0.18in) -- cycle;
    \draw[linegray] (0,-0.06in) -- (-0.06in,-0.12in) -- (0in,-0.18in);
  \end{tikzpicture}
  \vspace{.05in}\\
}

\def\time#1#2{
  \hphantom{.}\hfil\begin{tikzpicture}
    \draw (0,0) node[scale=.65] {\color{kiktimepalegray}#1 \color{kiktimedarkgray}@ #2};
  \end{tikzpicture}\hfil\\
}

and this is Guia.tex:

\documentclass{whatsapp}

\setPartnerName{Dave Johnson}
%\setPartnerPic{Man.jpg}
\setHours{12}
\setMinutes{11}

\begin{document}
    \you{Knock knock}
    \me{Who's there?}
    \you{Canoe}
    \me{Canoe who?}
    \you{Canoe help me with my homework?}
    \time{Fri}{12:03 PM}
    \you{...please. I'm gonna fail calculus. :-(}
    \me{...}
\end{document}

Without errors

Since the problem is the paper size, I realize that deleting lines 57-127 (the Background part) it compiles without errors:

Without errors

So the problem is around the Background section of the whatsapp class.

Can anyone help me discovering the error(s)?

EDIT Since some users compile Guia.tex using whatsapp.cls without errors I add the log file after one compilaton of Guia.tex: https://pastebin.com/H1Q5qMzi (sorry for the link but the log was too long.)

  • On my machine it compiles without errors. What do I need to change to reproduce the error? – user194703 Feb 22 at 23:42
  • @Schrödinger'scat thank you for your feedback! Did you use whatsapp.cls? I just copied it and it gives me errors. I will add the log file for clarification. – manooooh Feb 22 at 23:45
  • Yes, I copied the snippet in your code that starts with % whatsapp.cls and called it whatsapp.cls. Of course, I made sure that it gets loaded. I get zillions of warnings but no errors. I compile with pdflatex. – user194703 Feb 22 at 23:47
  • @Schrödinger'scat did you write whatsapp.cls on a editor and save it as .cls? And created a .tex and copied the Guia.tex on the same folder directory? I have no idea why you have no errors. Do you have uncommented [a4paper]{geometry} on line 23, and commented the line 22? – manooooh Feb 22 at 23:52
  • 1
    I was not trying to suggest that you hit return. Rather, I think you should try to write a cleaner class file, which uses tikzpagenodes. BTW, there is an error on the headlines of the exercise guide, "make" should probably read "bake". ;-) – user194703 Feb 23 at 1:33

Your Answer

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

Browse other questions tagged or ask your own question.