Main

On-surface synthesis provides unique opportunities in the synthesis of crystalline two-dimensional polymers (2DPs) over large areas1,2,3,4,5. The advantage of on-surface synthetic methods is that they can be coupled with scanning tunnelling microscopy (STM), which provides a way not only to visualize and characterize the 2DPs with (sub)molecular resolution but also to investigate 2DPs growth and crystallization6,7,8,9,10. This approach is particularly powerful when carried out in the liquid–substrate interface as it brings together the power of solution synthesis and the templating power of an atomically flat surface. 2DPs synthesized from dissolved monomers at the solution–substrate interface benefit from a solvent-facilitated process and can undergo error corrections owing to bonding reversibility. By contrast, these processes are significantly limited without solvent, hindering the formation of highly crystalline domains with long-range order during thermal evaporation in vacuum11,12,13.

While there have been enormous advances in the synthesis of monolayers of 2DPs, the synthesis of stacks remains undeveloped. This is of particular interest as the stacking14 and/or twisting15,16,17,18 of 2D materials in bilayers or multilayers can generate new materials with properties that differ completely from those of the individual layers. The controlled synthesis of such twisted and/or stacked homo- or heterostructures is generally carried out by slow top-down processes (for example, exfoliate-and-stack or tear-and-stack methods) with low sample-to-sample reproducibility14,19. Conversely, the controlled synthesis of 2DP bilayers by bottom-up methods remains a challenge, and their formation has been rarely observed20,21,22. Understanding the second layer stacking process is particularly important in 2D covalent organic frameworks (COFs) (crystalline stacks of 2DPs) whose crystallinity is undermined often by stacking fault in the c axis owing to rotational misalignment of one layer with respect to another23,24,25. Interlayer coupling also plays a vital role in the determination of structure–property relationships, such as pore geometry, interaction with guest molecules, and optical and electronic properties26,27,28. In contrast to the straightforward imine or boroxine coupling during the in-plane growth of 2DPs29,30, a complex interplay of van der Waals, electrostatic and hydrogen bonding influences the nucleation and growth of the second layer. In particular, the topology and functional groups of the monomers may have a fundamental effect on the stacking registry of the second layer in the growth of 2D COFs28.

In this Article, we describe a method for synthesizing bilayer 2D COFs at the liquid–substrate interface through the direct condensation of monomers. More importantly, we also show how factors such as monomer structure and solvent mixture influence the bilayer stacking modes and how, under certain conditions, large-area moiré superlattices emerge from twisted bilayer stacking. For instance, using boroxine polymerization chemistry, we have verified that the use of heptanoic or octanoic acid as solvent results only in monolayer COFs, consistent with many previous studies, in which no bilayer COF formation was observed. We discover that crossing over to the bilayer regime required the use of a mixed solvent protocol, of which dimethyl sulfoxide (DMSO) increases the solubility of monomer precursor, while 1,2,4-trichlorobenzene (TCB) serves as a non-volatile solvent. We optimized the reaction conditions to focus on 2D polymerization and layer stacking processes, and to avoid the formation of kinetically trapped self-assembly. We found that the use of asymmetrical building blocks enables the growth of moiré 2D COF superlattices with reproducible and consistent twist angles across large areas (Fig. 1).

Fig. 1: Bilayer 2D COFs monitored in real-time and designable moiré superlattice formation.
figure 1

a, Schematic illustration of in situ STM experiments with the use of liquid cell mounted on top of the HOPG substrate. b, Molecular precursors designed for bilayer 2D boroxine-based COFs and twisted bilayer formation with uniquely different twist angles and moiré superlattice driven by interlayer interactions.

Results and discussion

Dynamic bilayer COF formation

Room temperature deposition of pyrene-2,7-diboronic acid (hereafter called 27-PDBA) solution (volume = 50 μl, concentration = 10 μM) onto a freshly cleaved highly oriented pyrolytic graphite (HOPG) surface resulted in the formation of a dominant phase A (Fig. 2a,b). High-resolution STM image revealed that phase A is a periodic porous structure. Fast Fourier transform (FFT) analysis reveals a hexagonal lattice with a cell constant of ACOFs-1 = BCOFs-1 = 2.0 ± 0.1 nm and γ = 60 ± 2° (Fig. 2c), which is in perfect agreement with the previously reported 27-PDBA-based surface COF system11. Bright and dark domains appeared within the same STM image, with the bright region approximately 0.14–0.18 nm higher than the dark region from the apparent height profile (Fig. 2d and Supplementary Fig. 1). We note that the two domains share the same crystallographic orientation, meaning that the contrast difference between them is not due to the different epitaxial relation between the COF adlayer and the substrate. The height of the as-synthesized thin film on HOPG is approximately 1 nm (Supplementary Fig. 2) measured by an atomic force microscope (AFM), which is consistent with bilayer 2D COF formation considering an interlayer distance of around 0.35 nm. We therefore ascribe the observed dark and bright domains to be the first and second layers of COFs. In most cases, we observed high coverage of the second layer; that is, the layer underneath is fully covered. ‘Scratching’ the surface with STM tip allows for the partial selective removal of top layers, and this confirms the bilayer nature of the COFs (Supplementary Fig. 3), as well as the registry of adlayers with respect to the substrate. Cofacial (or eclipsed) AA stacking, according to both theoretical studies31 (Supplementary Table 1) and experimental findings from 2D COFs24, is energetically unfavourable compared with the parallel displaced (PD) AA stacking with a translational displacement of 1–2 Å. However, thermal drift under ambient conditions prevents us from distinguishing cofacial and PD AA stacking.

Fig. 2: AA eclipsed/shifted stacking and their dynamic stacking processes.
figure 2

a, Chemical structure of the AA-stacked (eclipsed/translated) 2D COFs based on boroxine chemistry. b, High-resolution STM image revealing the partial coverage of the second layer on the first layer 2D COFs. c, FFT of b. Hexagonal feature of the 2DPs is outlined with white circles. d, Height profile extracted from the white line in b. e, Low-dose HRTEM image of AA eclipsed/shifted stacking 2D COFs along the <001> zone axis. f, FFT of e. g, Contrast transfer function corrected image of the white square area in e. h, Simulated projected electrostatic potential with a point spread function width of 1.0 Å. il, Large-scale STM images obtained during the vertical stacking and in-plane polymerization processes at time t = 0 min (i, j) and 16.2 min (k, l). Imaging conditions: 40 nm × 40 nm, Vs = 0.4 V, It = 0.08 nA (b); 500 nm × 500 nm, Vs = 0.4 V, It = 0.08 nA (i, k); 150 nm × 150 nm, Vs = 0.4 V, It = 0.08 nA (j, l); 18 nm × 18 nm (e); 3 nm × 3 nm (g).

Source data

To avoid beam damage (Supplementary Fig. 4), low-dose TEM was used to examine the 2D COFs stacked on graphene at atomic resolution, as depicted in Figs. 2e–h and 3d. The high-resolution transmission electron microscopy (HRTEM) image reveals the presence of cofacial AA stacking of the 2D COF and its perfect lattice registration with the graphene substrate. This results in a commensurate intensity modulation of the honeycomb lattice of graphene by the lattice vectors of 2D COF. The superimposed cofacial AA stacking of the 2D COF and graphene substrate manifests as a brighter, coarse-grained Kagome lattice overlay on the honeycomb lattice of graphene. These two distinct 2D crystal structures can be easily distinguished by the FFT pattern, where two sets of Bragg spots at high and low spatial frequencies correspond to the graphene substrate and 2D COF, respectively. Furthermore, the observed image contrast aligns well with the simulated projected electrostatic potential of the 2D COF/graphene heterostructure, demonstrating crystalline information transfer up to 1 Å, as indicated by the FFT pattern.

Fig. 3: Twisted bilayer moiré superstructure coexists with AA stacking.
figure 3

a, Chemical structure of the twisted 2D COF bilayer. b, Large-area STM image revealing the coexistence of twisted stacking (I) and AA stacking (II). c, High-resolution STM image revealing the moiré superlattice pattern. d, Low-dose HRTEM image of AA-stacked COF with a rotation angle of 9.2° along the <001> zone axis. Insets: the FFT pattern (upper right) of the HRTEM image with structural information transfer up to 1.0 Å. Imaging conditions: 250 nm × 250 nm, Vs = 0.3 V, It = 0.08 nA (b); 40 nm × 40 nm, Vs = 0.2 V, It = 0.01 nA (c); 36 nm × 36 nm (d).

In situ STM enables us to monitor the temporal evolution of the nucleation and growth process of the second layer, which may follow the Frank–van der Merwe (layer-by-layer), Stranski–Krastanov or Volmer–Weber growth mechanism. As shown in Fig. 2i–l, in the scanning region highlighted by the white squares, within a time interval of 16.2 min, there is an increase in the number (from 20 to 29) and coverage (from 28.6% to 41.2%) of brighter islands attributable to the newly formed layer on top of the bottom layer (darker region). A sequential view of the growth dynamics and the associated STM images can be found in Supplementary Figs. 5 and 6. The coexistence of monolayer as well as bilayer domains (Supplementary Fig. 7) clearly demonstrates a Frank–van der Merwe growth and the self-templating nature of the nucleation pathway for the AA-stacked phase. Larger domain grows by edge attachment of precursors and coalescence with other domains, similar to previously observed phenomena for monolayer 2D COFs11 (Supplementary Fig. 8). In addition, the formation of misaligned interface, as shown in Supplementary Fig. 9, is common to grain coalescence processes, where translational displacement prevents the attachment of two domains into a perfect single-crystal domain.

Moiré COF superlattice

Interestingly, as opposed to monolayer 2D COFs where only one phase is seen (common to all reports previously), we identify with STM a phase B (Fig. 3a,b) in addition to the AA-stacked phase A. The stacking in phase A is such that two layers share the same crystallographic orientations, whereas in phase B, the stacking shows a larger unit cell with periodic contrast modulation, as is characteristic of a moiré pattern. Figure 3b,c highlights a hexagonal moiré superlattice denoted by vectors Amoiré and Bmoiré at 120° to one another. The spatial periodicity of the moiré patterns and 2D COF lattice can be clearly distinguished in reciprocal lattice space. On the basis of the FFT analysis (Supplementary Fig. 10), the first-order spots of the hexagonal moiré and 2D COFs are labelled by inner and outer circles, respectively, enabling a direct measurement of the moiré length (Amoiré) and 2D COFs unit cell dimension (ACOFs-1) to be 12.5 nm and 2 nm, respectively. The height difference between the bilayer AA stacking and that of the superstructure is nearly zero (Supplementary Fig. 11). AFM measurements indicate a uniform film thickness of 1 nm, meaning that both phases A and B are bilayers. We note that short-range moiré fringes had been observed previously by TEM at the overlapping grain boundaries between stacked 2D polymers, but no method to produce a uniform long-range moiré pattern has been achieved32. The moiré pattern that we observed here most likely originates from the twisted stacking of one COF layer over another, similar to the case of twisted bilayer graphene15,33. The twist angle θ between two layers of 2D COFs can be determined from the measured ratio R = (Amoiré/ACOFs-1) of the lattice constants and the law of cosines34 known for twisted triangular lattices: 2*sin−1(1/2R) = 9.2°. The calculated crystallographic orientation relationship agrees with that determined from the ‘scratching’ experiment (Fig. 4 and Supplementary Fig. 12), where the top layer lattice is visualized (Fig. 4b,d) before scratching, and the underlying layer is exposed afterwards (Fig. 4c,e). We found that the top layer is rotated by approximately 9° relative to the bottom layer. Furthermore, the moiré pattern is only observed before the removal of the top layer, indicating that the appearance of the superlattice arises from the stacking of both layers. To reproduce the moiré patterns, we built a geometric model for the bilayer hexagonal lattice with a twist angle of 9.4° (Supplementary Fig. 13) and obtained the period length ratio of R equals 6.02, close to the value observed by STM imaging. We scanned the sample across larger areas and acquired more than 30 images of different regions where moiré superstructures are observed (Supplementary Fig. 14). Statistical analysis reveals that the moiré period lies in the range of 13.2 nm to 11.9 nm, with a predominant twist angle of 9.2° (Supplementary Fig. 15).

Fig. 4: Dynamic ‘scratching’ experiment revealing the registry of bilayer COFs.
figure 4

a, Schematic illustration of STM tip-assisted scratching and healing processes. b,c, STM image of phase B revealing the moiré pattern (b) and FFT pattern (c). d,e, STM image of the same domain (d), revealing the molecular arrangement of the underneath layer after the removal of the top layer, and the corresponding FFT image (e). White circles outline the 2 nm period of COF-1. Imaging conditions: Vs = 0.3 V, It = 0.08 nA (b, d). Scratching condition: Vs = 0.01 V, It = 0.8 nA. Scale bars are provided in each image.

Low-dose HRTEM imaging enabled the direct identification of stacking order in the 2D COF35,36,37,38. The image contrast confirms that the 2D COF has been successfully transferred to the graphene substrate (Supplementary Fig. 16). The HRTEM image clearly exhibits a moiré pattern with hexagonal symmetry on the honeycomb lattice of graphene (Fig. 3d), which is formed by two sets of Kagome lattice overlays rotated by ~9° with respect to each other as measured by their respective reciprocal lattice vectors in the FFT pattern. The optimized heterostructure model can be visualized in both wireframe and tiling representations (Supplementary Fig. 17). In addition, the lattice spacing (dgm) of the moiré pattern can also be quantitatively measured and related to the twisted angle (β) of bilayer COFs based on their respective lattice spacings (d1/d2) and the equation \({{d}}_{{\mathrm{gm}}}={{d}}_{{1}}{{d}}_{{2}}\times {({({{d}}_{{1}}{-{d}}_{{2}})}^{{2}}+{{d}}_{{1}}{{d}}_{{2}}{{\beta }}^{{2}})}^{-\frac{{1}}{{2}}}\), where dgm represents the lattice spacing of the moiré pattern, d1 and d2 represent the lattice spacings of the two individual layers, and β is the twisting angle between the layers. On the basis of the measured spacing of 13.7 nm for the moiré pattern, a twist angle of 9.2° is measured that matches well with the FFT measurement. Moreover, the superimposed carbon atomic columns of the heterostructure can be visualized in an enlarged region of the HRTEM image (Supplementary Fig. 18), which matches well with the heterostructure model embedded in the image. The above-mentioned experimental facts provided atomic-level experimental evidence for the presence of the bilayer COF with twisted stacking order.

It is instructive to ask if the population of the twisted versus non-twisted phases can be controlled via external triggers such as solvent, concentration and kinetic ripening. Changing the solvent from trichlorobenzene (TCB) to chlorobenzene (Supplementary Fig. 19) and o-dichlorobenzene (Supplementary Fig. 20) gave rise to well-ordered 2D COF formation, of which the coexistence of the twisted and non-twisted phase persists. The appearance of the twisted phase on these islands does not seem to be precursor concentration dependent as they formed even under sparse nucleation conditions (Supplementary Fig. 21). When a small domain of the non-twisted phase is surrounded by twisted ones as shown in Supplementary Fig. 22, no apparent change in the size of the domains caused by the ripening process was observed even after 226 min, suggesting that there is an energy barrier for interconversion. This hypothesis is backed by density functional theory (DFT) calculations showing that an energy minimum exists for bilayer COFs with a twist angle of 8–10°, 16–18° and 30°, whose formation energy is close to the AA stacking (Fig. 5a).

Fig. 5: Deterministic twisted angle via interlayer interaction engineering.
figure 5

a, Calculated system energy variation as a function of the twisted angle between top and bottom COF layers normalized by pyrene unit. b, Electrostatic potential surface (Ha) for 27-(top) and 16-(bottom) PDBA periodic monolayers projected on the 0.05 eÅ−3 electron density isosurface. c, Large-scale STM image revealing the moiré superlattice formed by twisted bilayer 2D-COFs. d, FFT of c. The hexagonal arranged white circle points out the COFs-2 lattice, while the inner yellow hexagon indicates the superlattice. e, High-resolution STM image of the structure shown in c. Imaging conditions: 150 nm × 150 nm, Vs = 0.2 V, It = 0.12 nA (c); 40 nm × 40 nm, Vs = 0.2 V, It = 0.18 nA (e).

Source data

Uniform twisted bilayer stacking

While non-covalent interlayer interactions govern bilayer formation, we hypothesize that through rational precursor design, the electrostatic interaction energy should be enhanced for certain stacking angles, enabling deterministic phase control. To verify this, we synthesized pyrene-1,6-diboronic acid, hereafter called 16-PDBA. In 16-PDBA, the two boronic acid groups are rotated by 60° with respect to the horizontal axis of pyrene, instead of being parallel to the main axis of pyrene for 27-PDBA, and they form 2D COFs with reduced lattice constant (the calculated value is approximately 1.95 nm). Upon room temperature deposition of 16-PDBA solution (volume = 50 μl, concentration = 10 μM) onto HOPG, a dominant moiré-twisted phase (Fig. 5c,e) is formed. FFT analysis (Fig. 5d) reveals the first-order spots of moiré and COF-2 lattice, labelled by inner and outer circles, corresponding to the moiré length (Amoiré) and unit cell of COF-2 (ACOFs-2), which are measured 12.9 nm and 1.9 nm, respectively. The twist angle θ between two layers of COF-2 can thus be determined by θ = 2*sin−1(1/2R) = 8.4°. To reproduce the moiré patterns, we built a geometric model for the bilayer hexagonal lattice with a twist angle of 8.4° (Supplementary Fig. 23) and obtained a period length ratio R of 6.7, close to the value observed by STM imaging. From analysing STM images of 19 different regions where moiré superstructures are observed (Supplementary Fig. 24), the moiré lengths lie in the range of 12.9 nm to 11.9 nm, with the predominant twist angle at 8.4° (Supplementary Fig. 25). By scanning across the macroscopic length scale, we find that all the domains show the twisted phase, which is different from the earlier example using 27-PDBA. By annealing the sample at 50 °C for 1 h, the crystalline moiré regions were found to coexist with an amorphous phase rather than the non-twisted phase (Supplementary Fig. 26).

Why do we observe only a fixed angle twisted bilayer, rather than a range of twisting angles? This suggests the existence of a unique energy minimum state, where the twisted bilayer phase, with optimized interlayer interactions, is favoured over other configurations, such as AA stacking. To understand this, we evaluated computationally the energetics of COF islands of increasing sizes on an extended COF substrate with different stackings and twisting angles. All calculations were performed with an all-electron dispersion-corrected Perdew–Burke–Ernzerhof (PBE) Hamiltonian based on numeric atom-centred orbitals as implemented in the software FHI-aims39,40, which shows both remarkable accuracy and computational efficiency for this kind of material (Methods). For a minimal, one-pore, COF island made up of six 27-PDBAs, different minima regions were found with 8–10°, 16–18° and 30° twisting angles and improved binding compared with the AA stacking. These minima are stabilized by attractive dispersive pyrene–pyrene interlayer interactions that favour Bernal-like stacking. Furthermore, the analysis of the electrostatic contact potentials for periodic 27-PDBA and 16-PDBA monolayers (Fig. 5b) reveals that the electrostatic repulsive interactions between boroxine (–B–O–B–O–B–O–) rings aid the induction of twisted phases. For larger COFs, twist angles >10° are energetically not favoured (Supplementary Fig. 27), and only AA and twisted 8.4° phases are stable, with similar, barrier-separated, energies, which agree with the experimental observations. The 16-PDBA models reveal a fundamentally similar behaviour, with some differences as there are fewer minima and the barriers are lower (Fig. 5a and Supplementary Fig. 28). This is related to the subtle differences in the electrostatic potentials; for example, in 27-PDBA, there is a higher concentration of negative charges that manifest as lobes on the boroxine rings (Fig. 5b); this may hinder the formation of twisted phases compared with 16-PDBA that shows a flatter electrostatic potential.

The discovery of moiré superlattices resulting from twisted bilayer stacking highlights the ability to control the stacking dynamics through the choice of asymmetrical building blocks. It is also worth exploring COF linkages that can undergo tautomerization upon external cue by light or pH. Tautomerization can create variations in bond lengths and angles, which may affect the overall conformation of the 2D COF and, consequently, the twist angle between layers41. The uniqueness of bilayer COFs compared with inorganic layered crystals such as graphene is that in the latter, a deterministic control of the twist angle, or the formation of a single moiré-twisted phase, is not possible by spontaneous assembly owing to the near degeneracy of commensurately stacked layers of different twisted angles. The ability to finely tune the twist angles and stacking configurations opens up new avenues for designing materials with specific electronic and structural properties, which is crucial for applications in optoelectronics and nanotechnology. Therefore, we demonstrate that by rational design of the building blocks, it is possible to engineer bilayer stacking that forms exclusively moiré-twisted phase, paving the way to make inversion asymmetric bilayer systems with unique topological properties. These results highlight a robust strategy for the precise control of bilayer stacking in 2D COFs, offering new opportunities for the design of materials with tunable electronic and structural properties.

Methods

Chemicals and sample preparation

Pyrene-2,7-diboronic acid (27-PDBA) was synthesized as reported in the literature42. 1,2,4-trichlorobenzene (Sigma-Aldrich, ≥99%), 1,2-dichlorobenzene (Sigma-Aldrich, ≥99%), chlorobenzene (Sigma-Aldrich, ≥99%) and DMSO (Sigma-Aldrich, ≥99%) were used without further purification. 1,6-Dibromopyrene was purchased from BLD Pharmatech. Anhydrous tetrahydrofuran (THF), trimethyl borate and 2 M n-butyllithium solution in cyclohexane were purchased from Sigma-Aldrich. All reagents were used without further purification. Solvents were obtained from commercial suppliers and used without further purification. Solutions of 27-PDBA and 16-PDBA were prepared by dissolving the solid sample in DMSO (1 mg g−1) and further diluted with 1,2,4-trichlorobenzene/1,2-dichlorobenzene/chlorobenzene to generate concentration series. The TEM test this time used an Au grid provided by Beijing Graphene Institute (BGI), with the specific parameters being Quantifoil R1.2 on Au 300 mesh.

Synthesis of pyrene-1,6-diyldiboronic acid (16-PDBA)

The synthetic procedure of pyrene-1,6-diyldiboronic acid was adapted from the reported procedure43 with slight modification: 1,6-dibromopyrene (2.5 mmol, 0.9 g) was suspended in 15 ml anhydrous THF. The mixture was cooled to −78 °C using a dry ice–acetone bath and then 3 ml n-butyllithium solution (2 M in cyclohexane) was added dropwise, which was kept at −78 °C and reacted for 3 h. Trimethyl borate (12.5 mmol, 1.3 g) was injected dropwise. Then the mixture was reacted for 3 h at −78 °C and warmed to room temperature and further reacted overnight. HCl solution (2 M) was added to acidify the system and THF was removed under vacuum. The solid was filtered and washed with water to give the crude product. The crude product was suspended in toluene and sonicated for 0.5 h and filtered to give the product as yellow powder. Yield: 28%. Nuclear magnetic resonance spectroscopy (NMR; Supplementary Figs. 29 and 30): 1H and 13C NMR spectra were acquired on a Bruker AMX400 (400 MHz) spectrometer. Residual solvent peak was used as an internal reference to calibrate the spectra (DMSO, 2.5 ppm for 1H NMR, 39.52 ppm for 13C NMR).

In situ STM measurements

All experiments were performed at room temperature using a PicoLE (Agilent) machine operating in constant-current mode. STM tips were prepared by mechanical cutting from Pt/Ir wire (80/20, diameter 0.25 mm, Advent Research Materials). HOPG (grade ZYB, Momentive Performance Material Quartz) was used as the substrate for STM measurements at the solid–liquid interface under ambient conditions. Several samples were investigated, and for each sample, several locations were probed. The annealing experiment shown in Supplementary Fig. 26 was performed in the presence of the mixed solvent (DMSO/TCB). The bias voltage refers to the substrate. STM images were processed using Scanning Probe Image Processor (SPIP, Image Metrology ApS) software. Imaging parameters for the STM images are indicated in the figure captions and denoted by Vs for sample bias and It for tunnelling current.

TEM measurements

The low-dose HRTEM images were acquired on a 300 kV Thermo Fisher Themis ETEM equipped with a Gatan K3 direct electron detection camera operated in the electron counting mode. The low-dose HRTEM image series are acquired using dose fractionation, followed by image registration and correction of contrast transfer function according to a previously reported procedure (unravelling surface and interfacial structures of a metal–organic framework by transmission electron microscopy).

AFM measurements

The morphology of thin films was investigated by a ScanAsyst model AFM (Bruker Dimension Icon with a Nanoscope V controller) under ambient conditions. The probe consisted of a sharp silicon tip (SCANASYST-AIR; thickness, 2.5–8.0 μm; length, 115 μm; width, 25 μm; resonance frequency, 70 kHz; spring constant, 0.4 N m−1) attached to a silicon nitride cantilever. Scan frequencies of 0.6 Hz were used for good imaging conditions. AFM images were analysed with the software WSXM.

DFT calculations

Periodic DFT calculations were done using Fritz Haber Institute ab initio molecular simulations (FHI-aims)44,45,46 using the PBE39 functional augmented with many-body dispersion corrections40. Geometrical relaxations were performed using ‘light’ numerical orbitals and a Γ-only k-point grid, as this procedure has been successfully used in the past to produce high-quality molecular structure predictions in 2D and 3D COFs47,48. Structures were optimized with fixed cell angles with a maximal force threshold of 0.02 eV Å−1. The substrate was fixed in all calculations. The non-periodic COF was rotated around its centre of mass up to the desired twist angle and then relaxed. Single-point energy calculations using the ‘tight’ numerical orbitals were performed on the relaxed structures to obtain the final energies. The binding energies were calculated as EAB = EA − EB, where A and B refer to the two different layers of the system (substrate, adsorbed COF) and all energies refer to relaxed structures. The periodic twisted COF bilayers were built using the Twister package49. Atomic representation was obtained using VMD50.

Twisting energetics of COF islands on extended COF substrates

DFT calculations on the smallest COF island featuring a single pore, as reported in the main text (Fig. 5a), confirm the existence of stable local minima at different twisted angles, one of which (8.4°) is remarkably close to the experimental observations. In addition, a model of a larger COF, namely a 27-PDBA 12-mer (Supplementary Fig. 27a) on a 4 × 4 27-PDBA substrate, was used to compute the energetics for all the twist angles for which a minimum was found as well as for the untwisted stacking. For this system (Supplementary Fig. 27b), the larger angle twists minima disappear and only two minima remain, namely the untwisted with PD stacking and 8.4° twisted phase. The energies of the untwisted and twisted stacking are very similar, with an energy difference of 0.92 kJ mol−1 per pyrene unit. Compared with the hexamer, this COF island was built by adding 6 PDBA branches to the initial, one-pore system. This is relevant, as for larger twist angles those branches progressively show reduced overlap with the substrate until they are standing upon an empty pore of the COF underneath at a twist angle of 30° (Supplementary Fig. 27a). This decreases the overall energy of the system, resulting in an energy penalty for the conformations with larger twist angles. The same mechanism is present also in the 16-PDBA COF. To further assess the growing size effect, a larger, 15-pyrene hydrogen-passivated COF was also considered, where we comparatively computed the energetics of untwisted and twisted 8.4° stackings. Two different rotation axes were considered: one across the centre of mass of the molecule and one across the centre of one of the pores (Supplementary Fig. 27c,d). The energies for this COF (open symbols in Supplementary Fig. 27b) are aligned with those of the 12-pyrene COF. For this system, the untwisted stacking is the most favourable one, while the 8.4° twisted AA conformation rotated around its centre of mass is slightly less favourable, with a binding energy difference of 2.39 kJ mol−1 per pyrene unit. The pore-centred rotation is less binding, with a calculated difference in binding energy of 3.60 kJ mol−1 per pyrene unit with respect to the untwisted case. All these calculations indicate that the observed twisted stacking phases are seeded in the smaller growing COFs where they have comparable energetics with the PD untwisted stackings.

Simulation of twisted bilayer versus AA-slipped configuration

In addition, a second set of DFT calculations incorporating D3 dispersion corrections were conducted with Vienna Ab initio Simulation Packages (VASP)51,52. The PBE of generalized gradient approximation is used for the exchange-correlation potential and the plane-wave cut-off was set to 400 eV. The smallest moiré unit consisting of two layers (the layer distance is 3.45 Å) of COF was established, containing 24 monomers (–[C16B2O4H8]–). It is placed in a 60 × 60 × 20 Å3 unit cell to avoid boundary disturbances during rotation operations. To obtain structures with different angles, we fixed the bottom layer and then rotated the first layer by a certain angle. A G-centred 1 × 1 × 2 k mesh is used in the structure optimization process. The total energy criterion of 10−5 eV is set for each step of calculations, and all the atoms were relaxed until Hellmann–Feynman forces on each atom were reduced to less than 0.02 eV Å−1.

We note that the model’s limited size can only be used to test the principle of whether a local or global energy minimum exists for a specific twist angle in the twisted bilayer that is close to the energy of the AA-stacked or AA-slip stacked. We would like to verify if this energy minimum is unique for one particular twist angle. Utilizing DFT, we investigated the influence of the twist angle on structural energies. Supplementary Figs. 13, 27 and 28 and Supplementary Table 1 show that local energy minima occur at 8.4° and 9.2° for 16-PDBA and 27-PDBA, respectively, which agrees with the experimental rotation angles (8.4° for 16-PDBA and 9.2° for 27-PDBA). Therefore, this verifies the hypothesis that the twisted angle is unique. We note the existence of saddle points and global energy minima for AA-slip configurations for both 27-PDBA and 16-PDBA, with energies that are slightly more exothermic than the twisted angle. In the case of 27-PDBA, the global energy minima (AA-slip) are more stable than the local energy minima (9.2°-twist) by 0.33 eV per unit, whereas for 16-PDBA, the energy difference reduces to 0.06 eV per unit. AA-slip refers to the situation where one layer is translated in-plane by a distance corresponding to one C–C bond length (1.36 Å), and we find that AA-slip is more stable than eclipsed AA owing to the minimization of electrostatic repulsion. The AA-slip structure likely corresponds to the experimentally observed AA/AB structures. We note that the limited size of our model may not reveal the relative stability of the AA-slip or twisted angle accurately, but the results verify that the twisted bilayer phase observed a unique twist angle that is very close in energy to the AA-slip stacked configuration, and that in the case of 16-PDBA, there is a greater probability for the twisted bilayer to manifest since the energy difference between twisted and AA-slip is small.