## Methods and Materials
### Optimization of Waveguide Geometry of PhC NB Cavity Structure with a Horizontal Air Gap
Here, we employed three different modulation functions; linear, quadratic, and cubic functions. The cavity mode of cubic modulation has a slightly higher \(S\) than that of quadratic modulation because the air hole near the center is slightly larger. However, the Q-factor of the cavity mode of quadratic modulation is 8% higher than that of cubic modulation due to a relatively strong PBG effect. Next, we optimized the variation of the air hole to achieve the maximal Q-factor. Figure 3b shows the Q-factor and \(S\) as functions of the variation in the size of air holes. Q achieved a maximum value of approximately 970 at \(\Delta r=0.12r_{0}\), which is limited by the waveguide loss. To understand the optimal condition of waveguide loss, mirror strength (\(\gamma\)), as shown in the inset graph of Figure 3b, was calculated using the following equation [10,18]:  
\[\gamma=[(\omega_{2}-\omega_{1})^{2}/(\omega_{2}+\omega_{1})^{2}\text{ - }(\omega_{\text{res}}\text{ - }\omega_{0})^{2}/\ \omega_{0}^{2}]^{1/2} \tag{3}\]  
where \(\omega_{1}\) and \(\omega_{2}\) are the frequencies of the first band edge mode and third band edge mode, respectively, in the PhC NB structure with \(r_{bm}\) obtained from Figure 1b. \(\omega_{0}\) and \(\omega_{\text{res}}\) are the mid-gap frequency (\(=(\omega_{2}+\omega_{1})/2\)) and resonant frequency of the air gap cavity mode, respectively, calculated using the FDTD method. According to the mirror strength, the strongest PBG effect is observed around \(\Delta r/r_{0}=0.1\), and therefore, the waveguide loss is minimized. Even though the PBG effect is maximized, the Q-factor is less than 1000, which is not enough for gas sensing. Fortunately, the PBG effect can be strengthened by simply adding mirror air holes. To examine this, we investigated the changes in the Q-factor and \(S\) as the number of mirror holes increased. For the quantitative analysis and maximization of the Q-factor and \(S\) of the air gap cavity mode, we investigated the loss mechanism. As mentioned earlier, the material loss was ignored because Si is a lossless material at a wavelength of 1.55 \(\upmu\)m. Therefore, the total loss, \(\alpha_{\text{tot}}\), is caused by the leakage of light, which can be expressed as  
Figure 2: Optimization of the waveguide structure of a PhC NB cavity for refractive index sensing. (**a**) Schematics of the PhC NB cavity structure with a horizontal air gap; (**b**) \(x\)–\(y\) and \(x\)–\(z\) cut-views of \(E_{z}\) field distribution of the air gap cavity mode when width \(w=0.95\ a\), thickness of air gap \(t_{\text{g}}=0.15\ a\), and size variation of air holes \(\Delta r/r_{0}=0.10\); Q-factor (black square) and sensitivity \(S\) (nm/RIU) (blue circle) as a function of (**c**) width (\(w\)) of the PhC NB and (**d**) thickness (\(t_{\text{g}}\)) of the air gap. \(\alpha_{y}+\alpha_{z}\) where \(\alpha_{i}\) indicates the optical loss along \(i\)-axis (the axis direction is shown in Figure 2a). If this equation is re-expressed in terms of the Q-factor, then  
\[1/\mathrm{Q_{tot}}=1/\mathrm{Q_{x}}+1/\mathrm{Q_{y}}+1/\mathrm{Q_{z}} \tag{4}\]  
From the simulation, all the Q-factors were obtained by carrying out Poynting flux calculations. Figure 3c shows that adding more mirror holes reduces the waveguide loss. From these results, we could simultaneously obtain a very high sensitivity (~1020) and a high Q-factor (>40,000) from the TM cavity mode in an optimized PhC NB with an air gap. As shown in Figure 2d, there is trade-off between the Q-factor and \(S\) in the air gap cavity mode in the PhC NB cavity with the horizontal air gap, because a thick horizontal air gap increases the optical sensitivity but decreases the light confinement. Therefore, there is an optimal condition for both a high Q-factor and sensitivity. For the practical design of the optical sensor, we numerically investigated the Q-factor and \(S\) of the air gap cavity mode with various thicknesses of the Si waveguide and horizontal air gaps.