How do you create pagination links related to entries within a Matrix Field in a single entry?
In this particular case, .relatedTo(entry) is not necessary. So long the entry the following code is located within is within the entry within the source the pagination will populate. Otherwise these will remain empty.

{% set source = craft.entries.sectionId(10).first().gallery.type('gallery').first().entries %}

{% set prevEntry = entry.getPrev(source) %}
{% set nextEntry = entry.getNext(source) %}

&lt;a href="{{ nextEntry.url }}"&gt;Next: {{ nextEntry.title }}&lt;/a&gt;
&lt;a href="{{ prevEntry.url }}"&gt;Previous: {{ prevEntry.title }}&lt;/a&gt;