Display entries by category (multiple categories)
You can use .relatedTo(category)

{% for category in craft.categories.group('categoryName') %}
  &lt;h2&gt;{{category.title}}&lt;/h2&gt;
  {% for entry in craft.entries.section('news').relatedTo(category) %}
    &lt;a href="{{entry.url}}"&gt;{{entry.title}}&lt;/a&gt;&lt;br&gt;
  {% endfor %}
{% endfor %}


You can check for length if you don't want to show categories which aren't related to any entry.

See the relations documentation