  Two-dimensional materials on metallic surfaces or stacked one on top of the
other can form a variety of moir\'e superstructures depending on the possible
parameter and symmetry mismatch and misorientation angle. In most cases, such
as incommensurate lattices or identical lattices but with a small twist angle,
the common periodicity may be very large, thus making numerical simulations
prohibitive. We propose here a general procedure to determine the minimal
simulation cell which approximates, within a certain tolerance and a certain
size, the primitive cell of the common superlattice, given the two interfacing
lattices and the relative orientation angle. As case studies to validate our
procedure, we report two applications of particular interest: the case of
misaligned hexagonal/hexagonal identical lattices, describing a twisted
graphene bilayer or a graphene monolayer grown on Ni(111), and the case of
hexagonal/square lattices, describing for instance a graphene monolayer grown
on Ni(100) surface. The first one, which has also analytic solutions,
constitutes a solid benchmark for the algorithm; the second one shows that a
very nice description of the experimental observations can be obtained also
using the resulting relatively small coincidence cells.
