Evolution of resource specialisation in competitive metacommunities

Abstract Spatial environmental heterogeneity coupled with dispersal can promote ecological persistence of diverse metacommunities. Does this premise hold when metacommunities evolve? Using a two‐resource competition model, we studied the evolution of resource‐uptake specialisation as a function of resource type (substitutable to essential) and shape of the trade‐off between resource uptake affinities (generalist‐ to specialist‐favouring). In spatially homogeneous environments, evolutionarily stable coexistence of consumers is only possible for sufficiently substitutable resources and specialist‐favouring trade‐offs. Remarkably, these same conditions yield comparatively low diversity in heterogeneous environments, because they promote sympatric evolution of two opposite resource specialists that, together, monopolise the two resources everywhere. Consumer diversity is instead maximised for intermediate trade‐offs and clearly substitutable or clearly essential resources, where evolved metacommunities are characterised by contrasting selection regimes. Taken together, our results present new insights into resource‐competition‐mediated evolutionarily stable diversity in homogeneous and heterogeneous environments, which should be applicable to a wide range of systems.

In this appendix we derive the analytical results for the homogeneous model, and some limited results for the heterogeneous model.

S1.1 Homogeneous environments
For spatially homogeneous systems, we study the model du i dt = (G(a i1 R 1 , a i2 R 2 ) − µ)u i (S1.1a) (S1.1c) Here we have assumed for simplicity that the supply rate as well as the renewal rate of both resources are 1 (this is only a matter of scaling). a 1 and a 2 are the affinities for resources 1 and 2, and are nonnegative. We assume that trade-off curves pass through the point a 1 = a 2 = 1, and are symmetric around the diagonal line in the a 1 a 2 -plane. For a generalist consumer, i.e., a consumer with a 1 = a 2 = 1, we assume that the zero net growth isocline (ZNGI) passes through the point R 1 = R 2 = R 0 , and that this generalist ZNGI is symmetric around the diagonal in the R 1 R 2 -plane, or stated differently, that G(X, Y ) = G(Y, X). Note that this assumption implies that the function G is the same function for all consumers, and the only traits that differentiate the consumers are their affinities. Also note that if X = Y = R 0 , then G(X, Y ) − µ = 0. Furthermore we assume that C 1 + C 2 ≡ 1, and that C 1 ≥ 0 and C 2 ≥ 0. Since we are interested in the evolution of resource uptake, we also assume that ∂C 1 /∂(a 1 R 1 ) ≥ 0 and ∂C 2 /∂(a 2 R 2 ) ≥ 0, and that a 1 R 1 ≥ a 2 R 2 =⇒ C 1 ≥ C 2 .
Given these premises, we will show that there exists a generalist ZNGI, which we term the "critical generalist ZNGI", that separates two distinct ecological and evolutionary regimes. This critical generalist ZNGI is given by R 1 R 2 = R 2 0 when a 1 = a 2 = 1. We will show that for generalist ZNGIs lying entirely below this curve, evolutionarily stable coexistence between two consumers is always possible given a sufficiently specialist-favoring trade-off. Furthermore, we will show that resource types characterized by generalist ZNGIs lying entirely above this critical curve do not permit stable ecological coexistence between two consumers. For the purposes of our investigations, we can restate this as follows. If the zero level curve of G(X, Y ) − µ lies entirely below the critical level curve XY = R 2 0 , then evolutionarily stable coexistence is always possible given a sufficiently specialist-favoring trade-off. Conversely if the zero level curve of the function G(X, Y ) − µ lies entirely above the critical level curve, then ecological coexistence is impossible.
We do this by considering three different scenarios. First, we determine when evolutionary branchings are possible. We then determine when evolutionary branchings are not possible but evolutionarily stable coexistence nevertheless is. Finally, we determine when ecologically, and thus also evolutionarily, stable coexistence is impossible.

S1.1.1 Homogeneous environments: Evolutionary branchings
We start our investigations by determining when the point (a 1 , a 2 ) = (1, 1) will be an evolutionary branching point in the adaptive-dynamics sense (Geritz et al. 1998). We will show that if the generalist ZNGI of the consumer lies entirely above the critical generalist ZNGI, evolutionary branching is not possible for any trade-off. Conversely we will show that if the generalist ZNGI of the consumer lies entirely below the critical generalist ZNGI, we can always find a trade-off that engenders evolutionary branching.
We consider the monomorphic one-consumer system du dt = (G(a 1 R 1 , a 2 R 2 ) − µ)u (S1.2a) dR 1 dt = 1 − R 1 − C 1 (a 1 R 1 , a 2 R 2 )Gu (S1.2b) dR 2 dt = 1 − R 2 − C 2 (a 1 R 1 , a 2 R 2 )Gu . (S1.2c) We make the assumptions on the trade-off curves and ZNGIs as described after Eqs. S1.1. We first note that due to the symmetry of G, C 1 , and C 2 , if a 1 = a 2 = 1, then there must exist an equilibrium solution to the system above with R 1 = R 2 = R 0 (given that any positive solution for the consumer exists). For a generalist consumer to be in equilibrium, the equation for the ZNGI, G(1 · R 1 , 1 · R 2 ) − µ = 0 is satisfied. For any resource densities above this curve, the consumer would have positive growth rate.
Since the resource densities are both R 0 , this implies that we have a corresponding equation in affinity space, G(a 1 R 0 , a 2 R 0 ) − µ = 0, which will have the same shape as the generalist ZNGI, but scaled to go through the point a 1 = a 2 = 1. This curve is known as the invasion boundary (de Mazancourt & Dieckmann 2004). The invasion fitness of a rare mutant with a combination of affinities above this curve will be positive, whereas it will be negative for affinity combinations below this curve. For illustration, we show three examples of generalist ZNGIs (Fig. S1.1A) and their corresponding invasion boundaries ( Fig. S1.1B). Since the generalist ZNGI is symmetric around the diagonal, so will the invasion boundary, and the slope of the invasion boundary at a 1 = a 2 = 1 will be −1. Since trade-off curves are assumed to be symmetric around the diagonal line in affinity space, any trade-off curve will also have a slope of −1 at a 1 = a 2 = 1. Since the invasion boundary and the trade-off curve have the same slope at this point, the point (a 1 , a 2 ) = (1, 1) is an evolutionarily singular point (de Mazancourt & Dieckmann 2004).
If the trade-off curve lies entirely below the invasion boundary, it is not possible for any mutant with a combination of affinities on the trade-off curve to invade the resident, and the evolutionarily singular point is an evolutionarily stable strategy (ESS). Locally around the point a 1 = a 2 = 1, the behavior of the system will be determined by the curvatures of three curves: the trade-off curve, the invasion boundary, and something known as the attainability boundary, which delineates the areas in affinity space that can be reached through gradual small mutations (de Mazancourt & Dieckmann 2004). We denote these curvatures at the point a 1 = a 2 = 1 by κ T for the trade-off, κ Z for the invasion boundary, and κ A for the attainability boundary. The curvature of the invasion boundary κ Z is thus a scaled version of what we call the generalist ZNGI curvature in the main text, scaled into affinity space. In the following derivations we will express all analytical results in terms of the curvatures κ T and κ Z . However, in the main text and in all figures (in both the main text and the appendices), we have scaled κ T and κ Z by a factor √ 2 to reduce notational clutter. Table S1.1 gives an overview over all symbols and definitions of scaled and unscaled curvatures used in the main text, figures and appendices.
By de Mazancourt & Dieckmann (2004), evolutionary branching occurs if and only if (S1. 3) The curvatures κ Z and κ A can both be calculated from the generalist ZNGI, and the curvature κ T can be chosen independently of these, by choosing some specific trade-off curve. Thus, whether evolutionary .1: A: Examples of zero net growth isoclines (ZNGIs) in resource space for generalist consumers with affinities a 1 = a 2 = 1. B: Corresponding invasion boundaries for the consumers in affinity space in an equilibrium system where R 1 = R 2 = R 0 . Due to the construction of G, the ZNGIs and the corresponding invasion boundaries have the same shape, and only the scaling of the axes is different. Three cases are illustrated where resources are assumed to be perfectly substitutable (blue lines), complementary substitutable (black lines), and interactively essential (orange lines). Table S1.1: Symbols and definitions of curvatures used to characterize the trade-off curve, the generalist ZNGI, the invasion boundary, and the attainability boundary.

Main text and all figures in main text and appendices
κ U Unscaled curvature of the generalist ZNGI in resource space at the point (R 1 , R 2 ) = (R 0 , R 0 ) Derivation of invasion boundary curvature (Eq. S1.6) κ crit U Unscaled curvature of the critical generalist ZNGI in resource space at the point Derivation of critical invasion boundary curvature (Eq. S1.18) κ Z Curvature of the invasion boundary in affinity space at the point (a 1 , a 2 ) = (1, 1); equals the curvature of the generalist ZNGI scaled into affinity space; κ Z = R 0 κ U Appendix S1.1.1 and S1. Eq. S1.19 κ A Curvature of the attainability boundary in affinity space at the point (a 1 , a 2 ) = (1, 1) Appendix S1.1.1 and S1.1.2 branching is possible depends on whether κ Z < κ A , in which case we can always pick a trade-off such that κ T satisfies Eq. S1.3.
As noted above, the invasion boundary has the same shape as the generalist ZNGI, but scaled so that it goes through the point (1, 1) in affinity space, rather than (R 0 , R 0 ) in resource space. This implies that, if the unscaled curvature of the generalist ZNGI in resource space is κ U at the point (R 0 , R 0 ), then the curvature of the invasion boundary at (1, 1) in affinity space will be κ Z = R 0 κ U . Hence, we start by computing κ U in terms of derivatives of G. We let X = a 1 R 1 , and Y = a 2 R 2 . At the point a 1 = a 2 = 1, we have that ∂G/∂R 1 = ∂G/∂X and ∂G/∂R 2 = ∂G/∂Y . The formula for the curvature of an implicit curve f (x, y) = K is in general given by: For our problem the symmetry yields that for a 1 = a 2 = 1 and R 1 = R 2 = R 0 . Throughout the rest of this derivation, we will take all derivatives to be evaluated for these values of the affinities and resources without further comment. Using the expression for the curvature of an implicit curve yields: (S1.6) Since κ Z = R 0 κ U , we thus have an expression for κ Z : We can also derive an expression for the curvature of the attainability boundary, κ A . By de Mazancourt & Dieckmann (2004) this is given by: where G a 1 and G a 2 are the partial selection gradients at the point of interest. These are given by Due to symmetry, S A = −1 evaluated at (a 1 , a 2 ) = (1, 1). For notational convenience we let R s := ∂R 1 /∂a 1 = ∂R 2 /∂a 2 and R d := ∂R 1 /∂a 2 = ∂R 2 /∂a 1 and compute This yields: (S1.11) To calculate R s and R d we investigate the equilibrium equations: Combining the second and third line, using that C 1 + C 2 = 1, and assuming u > 0 we get the equations Differentiating the top equation with respect to a 1 yields: (S1.14) using that ∂G/∂X = ∂G/∂Y = G . Differentiating the bottom equation with respect to a 1 yields: where C := ∂C 1 /∂X = ∂C 2 /∂Y , and we have used that ∂C 1 /∂Y = −∂C 1 /∂X. Solving for R s and R d , we can compute: . (S1.16) Rewriting our expression for κ A (Eq. S1.11), we get: . (S1.17) Since R 0 < 1, and C ≥ 0, we can see that κ A > κ Z for κ Z < 1/ √ 2, and vice versa, unless C = 0, in which case κ A = κ Z . Since evolutionary branching is only possible when κ A > κ Z , we can conclude that evolutionary branching is only possible when κ Z < 1/ √ 2.
If the generalist ZNGI of the net growth function is given by the critical generalist ZNGI, R 1 R 2 = R 2 0 , we can calculate the curvature of this to be κ crit U = 1/( √ 2R 0 ), which implies that the curvature of the critical invasion boundary will be Hence, if a generalist ZNGI lies entirely below the critical generalist ZNGI, its curvature will be less than the curvature of the critical generalist ZNGI, which in turn means that the curvature of the associated invasion boundary will be less than 1/ √ 2. So, whenever a generalist ZNGI lies entirely below the critical generalist ZNGI, evolutionary branching is always possible, and will occur for a suitably chosen trade-off curve.
To simplify notation in the main text and in figures involving curvatures, we introduce the following normalized curvatures of ZNGIs and trade-off curveŝ In the main text and in all figures (including appendix figures), we use only these normalized curvatures.
For notational consistency, however, we continue to use the original curvatures κ T , κ Z and κ A in all following analytical derivations. Table S1.1 summarizes all symbols, definitions and scaling relationships between the different curvatures that are used in the main text and in the appendices.

S1.1.2 Homogeneous environments: Coexistence for trade-offs that do not yield branching
Here we will show that, if the generalist ZNGI of the consumers lies entirely below the critical generalist ZNGI, evolutionarily stable coexistence is possible for sufficiently specialist-favoring trade-offs, even if evolutionary branching does not occur.
Above, we showed that if κ Z < 1/ √ 2, then evolutionary branching leading to evolutionary coexistence is possible, and that this requires that the curvature of the invasion boundary satisfies κ Z < 1/ √ 2. However, not all trade-offs will yield evolutionary branchings. We make the assumption that the trade-off curve lies entirely below the invasion boundary if κ T < κ Z . In this case there will be no evolutionary branching and only a single generalist consumer can persist evolutionarily in the system.
The case that remains to be determined is when κ Z < κ T and κ A < κ T (whether κ Z < κ A or vice versa does not matter). When κ Z < κ T , the evolutionarily singular point (a 1 , a 2 ) = (1, 1) will be an evolutionary repellor (de Mazancourt & Dieckmann 2004), implying that any small perturbation away from the point will cause the consumer to evolve even further away from it. There are two types of possible endpoints of this directional evolution. In the first case, evolution continues until either a 1 or a 2 is zero. This leaves one of the resources unused and, due to symmetry, a mutant where the other affinity is zero can invade the system. Eventually, these two consumers will reach evolutionarily stable coexistence, each being specialized on an exclusive resource.
In the second case, evolution stops at some new evolutionarily singular point away from (a 1 , a 2 ) = (1, 1), where a 1 and a 2 are both nonzero. In the remainder of this section we will show that, if the generalist ZNGI of the consumers lies entirely below the critical generalist ZNGI, it is possible for a mutant to invade such a resident if the mutant's affinities are a mirror image of the resident's affinities, and that this results in a protected bimorphism that ensures evolutionary coexistence. This amounts to a scenario where the resident drives the resources to an equilibrium point (R * 1 , R * 2 ) that can be invaded by a mutant with exactly reversed affinities compared to the resident. Due to symmetry, switching the roles of mutant and resident would also have led to invasion, and hence mutual invasibility ensures that coexistence is possible. The proof is rather technical and requires both algebraic and graphical arguments.
Assume that (a 1 , a 2 ) = (1, 1) is an evolutionary repellor for a single consumer, leading to a new evolutionarily singular point at (a * 1 , a * 2 ), with a * 1 > a * 2 . The case with a * 1 < a * 2 will be the same due to symmetry. At this point, the system is in ecological equilibrium, with resource densities R * 1 , and R * 2 , and consumer density u * , obeying the equations Recall our assumptions that C 1 + C 2 ≡ 1, that a 1 R 1 > a 2 R 2 ⇐⇒ C 1 > C 2 , and that a 1 R 1 = a 2 R 2 ⇐⇒ C 1 = C 2 = 1/2. Given these premises we will show that (S1.21) These conditions are a prerequisite for our graphical argumentation further down. We will prove Eq. S1.21 by showing that any other combination, where one or more of the above inequalities is reversed, is impossible, case by case.
From our assumptions we also know that C 2 > C 1 . Since we are in equilibrium, it must be true that However, by the above inequalities this implies that 1 − R * 2 − C 2 Gu * < 0 , (S1.23) and so the system cannot be in equilibrium. This excludes case 1.
Under these circumstances we know that C 1 = C 2 = 1/2, and we get that R * 2 = a * 1 /a * 2 R * 1 . Since resource 1 is in equilibrium we have: However, this implies that since a 1 > a 2 . This excludes case 2.
Here C 1 > C 2 , and the system can be fulfilled, if and only if R * 1 < R * 2 . This proves Eq. S1.21.
Once the system described by Eqs. S1.20 has reached an evolutionarily singular point at (a * 1 , a * 2 ), it will have driven the system to a resource equilibrium (R * 1 , R * 2 ), which will be a point somewhere on the resident's ZNGI (blue line in Fig. S1.2A). We now ask ourselves whether a rare mutant with some given affinity combination on the trade-off curve will be able to invade the resident. Specifically, consider a mutant whose affinities a 1 and a 2 are the mirror images of the resident's affinities, so that a 1 = a * 2 and a 2 = a * 1 (Fig. S1.2B). For this given affinity combination, the mutant also has a ZNGI (dashed green line in Fig. S1.2A). If (R * 1 , R * 2 ) is a point above the mutant's ZNGI, then the mutant will be able to grow in the environment set by the resident, and thus be able to invade. So far, however, this is merely an illustration, and in order to show that an invader will always be successful given the premises detailed above, we need to make a somewhat roundabout argument.
Consider the curves in Fig. S1.2. Here, we see the resident's ZNGI (blue line in Fig. S1.2A) and the trade-off curve (orange line in Fig. S1.2B), both mapped into the scaled space with axes X = a 1 R 1 , and Y = a 2 R 2 (blue and orange lines in Fig. S1.2C). The resident's ZNGI is scaled by a * 1 and a * 2 , and the trade-off is scaled by R * 1 and R * 2 . This maps (a * 1 , a * 2 ) in Fig. S1.2B and (R * 1 , R * 2 ) in Fig. S1.2A onto the same point in scaled space, (X * , Y * ) = (a * 1 R * 1 , a * 2 R * 2 ) in Fig. S1.2C. As proved above it must hold that X * > Y * (since a * 1 > a * 2 , Eq. S1.21), so the point (X * , Y * ) is below the diagonal in scaled space. Recall that the ZNGI in scaled space is the same for all consumers, as the per capita growth rate of all consumers is governed by the same function G(X, Y ).
We now consider whether a mutant with a 1 = a * 2 and a 2 = a * 1 is able to invade the system. We know that the point (a 1 , a 2 ) is on the trade-off curve, due to the symmetry of the trade-off (Fig. S1.2B). For invasion to be possible, the net growth rate of the mutant must be positive, i.e., G(a 1 R * 1 , a 2 R * 2 ) − µ > 0. This is equivalent to the statement that the point (a 1 , a 2 ) in affinity space, when mapped into scaled space to the point (a 1 R * 1 , a 2 R * 2 ) must lie above the ZNGI in scaled space ( Fig. S1.2C). We will now show that this must be so.
Since it must be true that X * Y * = a * 1 R * 1 a * 2 R * 2 = a 1 R * 1 a 2 R * 2 we can conclude that the point (a 1 R * 1 , a 2 R * 2 ) must lie on a curve described by XY = X * Y * (black line in Fig. S1.2C). This curve is symmetrical about the diagonal in scaled space. Figure S1.2D shows a zoomed in and rotated part of Fig. S1.2C. We have assumed that the ZNGI in scaled space lies entirely below the critical generalist ZNGI (dashed line in Fig. S1.2D). Hence, both (X * , Y * ) and the curve XY = X * Y * lie below the critical generalist ZNGI as well. We can then conclude that the curve XY = X * Y * must intersect the ZNGI at two points that are symmetrical about the diagonal, (X * , Y * ) and (Y * , X * ), and that the curve XY = X * Y * lies below the ZNGI between these points and above the ZNGI outside of this interval. Hence, the curve XY = X * Y * lies above the ZNGI to the left of the point (Y * , X * ) (Fig. S1.2D). Thus, in order to show that the mutant with affinities (a 1 , a 2 ) has positive invasion fitness, it suffices to show that the point (a 1 R * 1 , a 2 R * 2 ) lies to the left of (Y * , X * ) = (a * 2 R * 2 , a * 1 R * 1 ) on the curve XY = X * Y * . This will be fulfilled if a 1 R * 1 < a * 2 R * 2 . Recall that a * 1 > a * 2 , that a 1 = a * 2 and a 2 = a * 1 , and that R * 2 > R * 1 by Eq. S1.21. Using these relations we can calculate (S1.27) Hence the point (a 1 R * 1 , a 2 R * 2 ) does indeed lie to the left of the point (Y * , X * ) = (a * 2 R * 2 , a * 1 R * 1 ) on the curve XY = X * Y * , and thus also above the ZNGI (Fig. S1.2C). Figure S1.2: A: Zero net growth isocline (ZNGI) of a resident consumer plotted in resources space. Also shown are the equilibrium resource densities (R * 1 , R * 2 ) in a system with only the resident, and the ZNGI of an invading mutant with affinities that are opposite to the resident's affinities. B: Trade-off curve, the evolutionarily singular point (a * 1 , a * 2 ), and the affinity combination of the invading mutant (a 1 , a 2 ) = (a * 2 , a * 1 ). C: The points and curves in A and B mapped into scaled space (X, Y ) = (a 1 R 1 , a 2 R 2 ), where the quantities in A have been scaled by a * 1 and a * 2 , and the quantities in B have been scaled by R * 1 and R * 2 . D: Rotated zoom-in of C, where the area depicted is indicated by the thin dashed box in C, with the critical generalist ZNGI added as a dotted line. We do not draw the critical generalist ZNGI in panel C to avoid visual clutter. In all panels the gray line indicates where x = y, for all axis variables. The figure is drawn based on a numerical simulation, as described in Appendix S2.1.1, with s = 0.75, a 0 = 5, and other parameters as in Table S2.1.
What this means is that a mutant with a 1 = a * 2 and a 2 = a * 1 will always be able to invade in this scenario, and due to the symmetry the reverse condition will also be true. This implies mutual invasibility and a protected bimorphism, as long as the generalist ZNGI lies entirely below the curve R 1 R 2 = R 2 0 . After the mutant and resident have achieved a new ecological equilibrium, they may still have to evolve directionally to achieve evolutionarily stable coexistence.
It is worth noting that, just as we have assumed ecological equilibrium dynamics, so, too, have we assumed evolutionary equilibrium dynamics. In principle, our arguments above cannot rule out evolutionary cycling, where the eco-evolutionary system oscillates between one and two consumers. However, under the assumption that no such cycles will occur, the arguments presented in this and the previous section suffice to prove that two consumers can coexist with evolutionary stability for sufficiently substitutable resources, and sufficiently specialist-favoring trade-offs.

S1.1.3 Homogeneous environments: Ecological coexistence is only possible if the generalist ZNGI lies below the critical generalist ZNGI
A necessary prerequisite for evolutionarily stable coexistence is stable ecological coexistence. Stable ecological coexistence of two resource competitors is only possible if, at equilibrium, each competitor is relatively more limited by a different resource, and if each competitor consumes relatively more of its more limiting resource (Tilman 1980). In the following, we will show that this condition is only fulfilled when the generalist ZNGI lies entirely below the critical generalist ZNGI. Conversely, if the generalist ZNGI of the consumers lies entirely above the critical generalist ZNGI, stable ecological coexistence-and hence evolutionarily stable coexistence-is impossible. We will only prove in detail the case for which coexistence is impossible, as the converse case follows from a fully analogous argument. Consider an equilibrium system with two coexisting consumers: Here, superscripts pertain to consumers, subscripts to resources, and asterisks indicate equilibrium densities of the resources and consumers. We note, again, that G 1 and G 2 are identical functions, but with different arguments, due to the differing affinities of the consumers. We assume that the affinities of the consumers are such that consumer 1 consumes relatively more of resource 1 than does consumer 2, i.e., C 1 1 /C 1 2 > C 2 1 /C 2 2 , where C i 1 /C i 2 corresponds to the slope of the consumption vector of consumer i (thin arrows in Fig. S1.3A). For stable coexistence to be possible, consumer 1 must then be relatively more limited by resource 1 than is consumer 2, i.e., it must hold that where the derivatives are evaluated at the equilibrium (R * 1 , R * 2 ). Graphically, (∂G i /∂R 2 )/(∂G i /∂R 1 ) is the slope of the normal vector (i.e., a vector perpendicular to the tangent) of the ZNGI of consumer i at the equilibrium point, which points relatively more in the direction of resource 1 if resource 1 is more limiting (illustrated by the thick red arrow belonging to ZNGI 2 in Fig. S1.3A), and relatively more in the direction of resource 2 if resource 2 is more limiting (thick blue arrow belonging to ZNGI 1, Fig. S1.3A). Thus, if consumer 1 consumes proportionally more of resource 1 than consumer 2, then the normal vector of the ZNGI for consumer 1, evaluated at the equilibrium, must point relatively more in the direction of resource 1 compared to consumer 2, in order for stable coexistence to be possible (note that the example in Fig. S1.3A illustrates the opposite case where coexistence is impossible).
Stated differently, if consumer 1 consumes proportionally more of resource 1 than consumer 2, then stable coexistence is only possible if the ZNGI of consumer 1 intersects the ZNGI of consumer 2 from above. In the following, we will show that this condition is only fulfilled when the generalist ZNGI lies entirely below the critical generalist ZNGI. We cannot prove this directly. Instead, we will introduce a third line R 1 R 2 = R * 1 R * 2 (gray line in Fig. S1.3A), which we can show is intersected from above by one of the ZNGIs, and from below by the other ZNGI.
As in the previous section, we introduce two new scaled variables, X = a 1 R 1 and Y = a 2 R 2 . Furthermore, let X 1 = a 1 1 R * 1 , Y 1 = a 1 2 R * 2 , X 2 = a 2 1 R * 1 , and Y 2 = a 2 2 R * 2 . In scaled X-Y space, both consumers have the same scaled ZNGI given by G(X, Y ) − µ = 0 (Fig. S1.3B), which is identical in shape to their generalist ZNGI (see Fig. 3 in main text). We note that our assumptions regarding the proportions of consumption imply that Hence, the point (X 1 , Y 1 ) must lie to the right of the point (X 2 , Y 2 ) on the scaled ZNGI ( Fig. S1.3B). We now draw two additional curves in scaled space, XY = X 1 Y 1 , which goes through the point (X 1 , Y 1 ), and XY = X 2 Y 2 , which goes through the point (X 2 , Y 2 ) ( Fig. S1.3B). Note that the scaled ZNGI of the consumers is tangent to the critical generalist ZNGI XY = R 2 0 in the point (R 0 , R 0 ), but lies everywhere else either entirely above or entirely below the critical ZNGI. In contrast, the curves XY = X 1 Y 1 and XY = X 2 Y 2 do not touch or intersect the critical generalist ZNGI XY = R 2 0 .
In the following, we assume that the scaled (= generalist) ZNGI lies above the critical generalist ZNGI. In this case, the two curves XY = X 1 Y 1 and XY = X 2 Y 2 must intersect the scaled ZNGI twice and in such a way that XY = X 2 Y 2 crosses the ZNGI from below at the point (X 2 , Y 2 ) and XY = X 1 Y 1 crosses the ZNGI from above at the point (X 1 , Y 1 ) (Fig. S1.3B). We can then go back from scaled space to resource space by rescaling the scaled ZNGI of consumer 1 and the curve XY = X 1 Y 1 by 1/a 1 1 and 1/a 1 2 in the R 1 and R 2 directions, respectively, and by rescaling the scaled ZNGI of consumer 2 and the curve XY = X 2 Y 2 by 1/a 2 1 and 1/a 2 2 in the R 1 and R 2 directions. Rescaling the curves in Fig. S1.3B into resource space will collapse the curves XY = X 1 Y 1 and XY = X 2 Y 2 onto a single curve described by R 1 R 2 = R * 1 R * 2 , whereas the scaled ZNGIs will become separate ZNGIs for consumer 1 and 2, respectively ( Fig. S1.3A). Since all we have done is rescale the coordinates, the order of slopes is preserved. Thus, since the scaled ZNGI crosses the curve XY = X 1 Y 1 from below in the point (X 1 , Y 1 ) (Fig. S1.3B), so will the ZNGI for consumer 1 cross the curve R 1 R 2 = R * 1 R * 2 from below in resource space at the point (R * 1 , R * 2 ) (Fig. S1.3A). By the same argument, the ZNGI for consumer 2 will cross the curve R 1 R 2 = R * 1 R * 2 -and thus also the ZNGI of consumer 1-from above in resource space. Thus, at equilibrium, the normal of the ZNGI of consumer 1 will point relatively more in the R 2 -direction compared to the normal of consumer 2, which is opposite to the order of the slopes of the consumption vectors of the two consumers (Fig. S1.3A). Hence, coexistence is not possible if the scaled (= generalist) ZNGI lies above the critical generalist ZNGI R 1 R 2 = R 2 0 (Fig. S1.3B). By an analogous argument, one can show that equilibria for generalist ZNGIs lying below the critical generalist ZNGI will yield stable equilibria.
In our argument (and in Fig. S1.3) we have for ease of illustration picked a case where a 1 1 > a 1 2 and a 2 2 > a 2 1 . Since a constant scaling of coordinates will preserve the order of angles between curves, the argument holds even without this provision.
ZNGIs 1 and 2 Figure S1.3: A: Zero net growth isoclines (ZNGIs) for two consumers that cannot coexist stably, the equilibrium resource densities (R * 1 , R * 2 ), and the curve R 1 R 2 = R * 1 R * 2 in resource space. Thick arrows are the normal vectors of the ZNGIs, and thin arrows are the consumption vectors of the consumers, where the lengths of the vectors have been normalized. B: The curves and points in A, mapped into scaled space (X, Y ) = (a 1 R 1 , a 2 R 2 ). The ZNGIs in A are mapped onto the same ZNGI in scaled space, by scaling ZNGI 1 by a 1 1 and a 1 2 , and ZNGI 2 by a 2 1 and a 2 2 . The point (R * 1 , R * 2 ) in A is mapped onto the points (X 1 , Y 1 ) = (a 1 1 R * 1 , a 1 2 R * 2 ) and (X 2 , Y 2 ) = (a 2 1 R * 1 , a 2 2 R * 2 ). The curve R 1 R 2 = R * 1 R * 2 is mapped onto the curves XY = X 1 Y 1 and XY = X 2 Y 2 . Note that to clearly show how lines intersect, the origin is not included in the scope of either panel. The figure is drawn based on a numerical simulation, as described in AppendixS2.1.1, with s = −1, a 0 = 10, and other parameters as in Table S2.1. The traits for the two consumers are χ 1 = −0.2 and χ 2 = 0.1.

S1.2.1 Heterogeneous environments: Why diversity is low near the critical generalist ZNGI
Here, we consider why we only get one or two coexisting consumers near the critical generalist ZNGI with curvature κ Z = 1/ √ 2 (corresponding toκ Z = 1 in Fig. 6 of the main text). More specifically, we consider why, if the generalist ZNGI of the net growth function is given by the critical generalist ZNGI R 1 R 2 = R 2 0 , we do not get more coexisting consumers. For the critical generalist ZNGI, we know that G(1 · R 1 , 1 · R 2 ) − µ = 0 has the solution R 1 R 2 = R 2 0 , which results in that G(X, Y ) − µ = 0 will have the solution XY = R 2 0 . If we now assume that the resources are of the same type for all resource densities (i.e., the resources will not, for example, change from substitutable to essential as resource densities increase), then all level curves of the function G(X, Y ) − µ will satisfy XY = c for some constant c that depends on which level curve we are considering. If so, then the function G(X, Y ) must be expressible as a function of only XY , so that G(X, Y ) = f (XY ). For example, the per capita growth function used in our numerical implementation for heterogeneous environments is given by (S1.31) when κ Z = 1/ √ 2, which is indeed only a function of the product of X and Y (see Eq. S2.2 and the subsequent paragraph in Appendix S2.1.1 for additional details concerning the specification of the model used in our numerical investigations).
In order for the consumers to be at an eco-evolutinoary equilibrium, the selection gradient for all consumers must be zero. We will now show that, when κ Z = 1/ √ 2 only one or two consumers will be able to coexist by showing that the selection gradient for residents can be zero for maximally two consumers. By Wickman et al. (2017), the selection gradient D(χ res ) acting on a trait value χ res for a resident with equilibrium density u res (x) in a reaction-diffusion system is given by (S1.33) In the expression above, ∂f (XY )/∂(XY ) will be positive, as we assume that the per capita growth function is increasing when resource availability increases, and R 1 and R 2 must be positive since they are resource densities. Hence, the sign of the above expression is determined by the factor d(a 1 (χ)a 2 (χ))/dχ. Since the affinities a j (χ) of a given phenotype are the same everywhere in space, it follows that ∂G(a 1 (χ)R 1 , a 2 (χ)R 2 )/∂χ| χ=χres is of one sign everywhere in space, and so the only way for the selection gradient (Eq. S1.32) to be zero is if the integrand is everywhere zero, i.e., if d(a 1 (χ)a 2 (χ))/dχ is zero. When the trade-off is generalist-favoring or mildly specialist-favoring, a 1 (χ)a 2 (χ) has a single maximum at the generalist trait combination a 1 = a 2 = 1. When the trade-off is sufficiently specialist-favoring, a 1 (χ)a 2 (χ) can have two maxima at some trait combination a 1 = a f > 1 and 0 < a 2 = a g < 1 and its mirror image a 1 = a g and a 2 = a f , separated by a local minimum at a 1 = a 2 = 1. Thus, near the critical generalist ZNGI, the evolutionarily stable equilibrium will consist of either a single generalist consumer or of two consumers that are relatively more specialized on opposite resources, depending on the shape of the trade-off.
In ecological terms this means that, in parameter space near the critical generalist ZNGI, we can distinguish two cases. (1) If the trade-off curve is linear to generalist favoring (κ T ≤ 0 in Fig. 6A), a 1 (χ)a 2 (χ) has a single maximum at the trait combination a 1 = a 2 = 1. This means that the ZNGI of a perfect generalist is below the ZNGIs of all other trait combinations on the trade-off curve. Consequently, the generalist will locally outcompete all other trait combinations everywhere in space, regardless of how skewed the local resource-supply ratios may be. For this case, the generalist-specialist dichotomy therefore loses its meaning, because 'specialists' cannot depress their favored resource to lower levels than a perfect generalist. In fact, on the critical generalist ZNGI and for linear or generalist-favoring trade-offs, competitive ability depends exclusively on the product a 1 (χ)a 2 (χ) (which is maximized for a 1 = a 2 = 1), and two consumers that are 'specialized' on opposite resources (a i1 > a i2 and a j1 < a j2 ) but have identical a i1 a i2 = a j1 a j2 also have identical ZNGIs.
(2) Alternatively, if the trade-off is sufficiently specialist-favoring (κ T > 0 in Fig. 6A), a 1 (χ)a 2 (χ) can have two maxima, in which case two (relative) specialists with opposite trait combinations will outcompete all other trait combinations.
These two cases can also be understood in terms of the graphical niche theory of geometrical envelopes developed by Koffel et al. (2016). This theory uses the outer geometrical envelope of the ZNGIs of all possible phenotypes/trait combinations-which, in our model, are all trait combinations (a 1 , a 2 ) on a given trade-off curve-to graphically derive the trait combination(s) that competitively exclude all other trait combinations at any given resource supply point (K 1 , K 2 ). In the case of resources of critical essentiality (i.e. resource types described by the critical generalist ZNGI), this outer geometrical envelope coincides with the critical generalist ZNGI when the trade-off is neutral to generalist-favoring (case 1 in the previous paragraph). The latter implies that the ZNGIs of all other phenotypes (a 1 = a 2 ) are nested inside (= above) the outer geometrical envelope represented by the critical generalist ZNGI R 1 R 2 = R 2 0 , and the generalist will locally outcompete all other trait combinations as long as the local resource supply point (K 1 , K 2 ) is above the envelope. In contrast, when the trade-off is sufficiently specialist-favoring (case 2 in the previous paragraph), the outer geometrical envelope consists of the outer parts of the intersecting ZNGIs of two (relative) specialists with exactly opposite trait combinations (a 1 , a 2 ). A combination of the upper left part of the solid ZNGI and the lower right part of the broken ZNGI in Fig. 5C of the main text can serve as an illustration of the general appearance of such a bisectional outer geometrical envelope. (Note, however, that the example of Fig. 5C is not located on the critical generalist ZNGI). In a spatially heterogeneous landscape, the two relative specialists will outcompete all other phenotypes, with the relative R 1 -specialist dominating where the local supply K 1 is low, and the relative R 2 -specialist dominating where the local supply K 2 is low.

S1.2.2 Heterogeneous environments: Correlation patterns of resource specialists with local resource supply
We state in the main text that, when resources are functionally substitutable (κ Z < 1 in Fig. 6A in the main text), consumers tend to be aligned with the local supply of their favored resource; i.e. resource specialists inhabit primarily those parts of the landscape where their favored resource has a high supply. Conversely, when resources are functionally essential (κ Z > 1), resource specialists tend to primarily inhabit parts of the landscape where their favored resource has low supply. While we cannot show this analytically, we can present supporting evidence from our numerical simulations in greater detail.
Let the resource supplies for the system be given by K 1 (x) and K 2 (x). For each consumer we calculate a measure of the experienced total supply of each resource as K E,1 = 1 u(x)dx K 1 (x)u(x)dx (S1.34a) (S1.34b) If local consumer density u(x) is closely aligned with the local supply of resource j across the landscape, then K E,j will be large. Conversely, if local consumer density is inversely related to the local supply of resource j, then K E,j will be small. Let a 1 and a 2 be the resource affinities of the consumer. We now calculate a measure of how aligned the consumer is with the local supply of its favored resource (i.e., the resource for which it has the higher affinity) as (S1.35) We calculated this favored resource alignment for all consumers across all communities from the numerical example in Fig. 6A of the main text, and depict the results in Fig. S1.4. There, we can clearly see that, for functionally substitutable resources (κ Z < 1), consumers are aligned with the local supply of their favored resource (A fav > 0), whereas for functionally essential resources (κ Z > 1), consumers are counter-aligned with the local supply of their favored resource (A fav < 0). This pattern can, again, be understood in terms of the graphical niche theory of outer geometrical envelopes developed by Koffel et al. (2016), see section S1.2.1. When resources are sufficiently essential (κ Z > 1 in Fig. 6A), the ZNGIs of many different trait combinations can be tangent to different parts of the outer geometrical envelope (e.g., Figs. 6B and C of the main text). This means that different trait combinations can outcompete all other trait combinations at localities in space where the local resource supply ratio K 1 /K 2 is inversely ranked to their affinity ratio a 1 /a 2 . Consequently, consumers are counter-aligned with the local supply of their favored resource when resources are essential (Figs. 6B and C of the main text). When resources are sufficiently substitutable (κ Z < 1 in Fig. 6A), it is also possible that the ZNGIs of several different trait combinations are tangent to different parts of the outer geometrical envelope, but only when the trade-off curvature fulfillsκ T <κ Z (e.g. Fig. 6E of the main text). When the reverse reverse is true (κ T >κ Z ), i.e., when the trade-off is sufficiently specialist-favoring, the outer geometrical envelope will be made up by the ZNGIs of the two extreme specialists (e.g. Fig.  6F of the main text), and these two specialists will, together, outcompete all other trait combinations everywhere on the landscape. Regardless of the relative ranking ofκ T andκ Z , substitutable resources enable consumers to become most abundant where the local supply of their favored resource is highest. Consequently, consumers are aligned with the local supply of their favored resource when resources are substitutable (Figs. 6E and F of the main text). Note that diffusive movement of resources and consumers blurs this picture, implying that local exclusion of phenotypes can strictly only occur when a phenotype is completely absent from the landscape.