How do I (also) cycle a class on a Matrix block? I think I am doing exactly the same as here but I only get the "even" class at each iteration.

{% for block in entry.articlebody %}

    {% set index0 = loop.index0 %}

    {% switch block.type %}

        {% case 'heading' %}
            &lt;h2 class="section-title"&gt;{{ block.heading }}&lt;/h2&gt;&lt;!-- /.section-title --&gt;

        {% case 'text' %}
            &lt;div class="{{ cycle(['odd', 'even'], index0) }}"&gt;{{ block.text }}&lt;/div&gt;    

    {% endswitch %}
{% endfor %}
The loop.index0 variable will be incremented for each block, regardless of type, so assuming every other block is a header, it's not surprising that the cycle method prints "even" for every text block.

I think what you need is a different variable which only increments whenever you hit a text block (note that this variable should be declared outside the for loop):

{% set textIndex = 0 %}

{% for block in entry.articlebody %}

    {% switch block.type %}

        {% case 'heading' %}
            &lt;h2 class="section-title"&gt;{{ block.heading }}&lt;/h2&gt;&lt;!-- /.section-title --&gt;

        {% case 'text' %}
            &lt;div class="{{ cycle(['odd', 'even'], textIndex) }}"&gt;{{ block.text }}&lt;/div&gt;
            {% set textIndex = textIndex + 1 %}

    {% endswitch %}
{% endfor %}