2

Would anyone have an idea on how to number blocks in a tikzposter, according to the order with which they are read in the tex file ? Ideally the block number would be of the form i/n, where n is the total number of blocks and i the number of the current one.

The outlook would be something similar to the outlook of the following tex file;

\documentclass{tikzposter}
\usepackage{lipsum}
\title{Template Poster}
\author{Author(s)}
\begin{document}
\maketitle
 \block{Basic Block}{Text \hfill (1/6)}
 \begin{columns}
\column{0.3333}% Width set relative to text width
\block{title}{\lipsum[1]
\hfill (2/6)}
\block{title}{\lipsum[2]
\hfill (3/6)}
\column{0.333}
\block{title}{\lipsum[3]
\hfill (4/6)}
\block{title}{\lipsum[1]
\hfill (5/6)}
\column{0.333}
\block{title}{\lipsum[4] 
\hfill(6/6)}

\end{columns}
\end{document}
3
  • Welcome to TeX.SE. If a "block" is a custom environment, then you could define a new counter, and increment it every time the environment is used. It's hard to help you more specifically, so I suggest you add a MWE.
    – anderstood
    Commented Jun 15, 2015 at 14:45
  • Thank you, I added a MWE, and will try to build a counter myself. I just didn't see how to know the total number of blocks prior to the compilation.
    – picop
    Commented Jun 15, 2015 at 15:00
  • You never know the total number before compiling, that's why you will need to compile twice: the total number will be deduced from the first compilation.
    – anderstood
    Commented Jun 15, 2015 at 15:59

1 Answer 1

2

Here's one possibility using the totcount package; process the document twice to get the value for the total number of blocks.

In this first approach, you use the \countblock command for every block that you want to be numbered:

\documentclass{tikzposter}
\usepackage{lipsum}
\usepackage{totcount}

\newtotcounter{myblocks}
\newcommand\countblock{%
  \stepcounter{myblocks}%
  \hfill (\themyblocks/\total{myblocks})%
}

\title{Template Poster}
\author{Author(s)}

\begin{document}

\maketitle

\block{Basic Block}{Text \countblock}
\begin{columns}
\column{0.3333}% Width set relative to text width
\block{title}{\lipsum[1]\countblock}
\block{title}{\lipsum[2]\countblock}
\column{0.333}
\block{title}{\lipsum[3]\countblock}
\block{title}{\lipsum[1]\countblock}
\column{0.333}
\block{title}{\lipsum[4]\countblock}
\end{columns}

\end{document}

enter image description here

In this second approach, the numbering is done automatically, by patching the \block command:

\documentclass{tikzposter}
\usepackage{lipsum}
\usepackage{totcount}
\usepackage{xpatch}

\makeatletter
\xpatchcmd{\block}
  {#3\par\normalsize}
  {#3\countblock\par\normalsize}
  {}
  {}
\makeatother

\newtotcounter{myblocks}
\newcommand\countblock{%
  \stepcounter{myblocks}%
  \hfill (\themyblocks/\total{myblocks})%
}

\title{Template Poster}
\author{Author(s)}

\begin{document}

\maketitle

\block{Basic Block}{Text}
\begin{columns}
\column{0.3333}% Width set relative to text width
\block{title}{\lipsum[1]}
\block{title}{\lipsum[2]}
\column{0.333}
\block{title}{\lipsum[3]}
\block{title}{\lipsum[1]}
\column{0.333}
\block{title}{\lipsum[4]}
\end{columns}

\end{document}
0

You must log in to answer this question.

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