We test whether Lyα emitters (LAEs) and Lyman-break galaxies (LBGs) can be good tracers of high-z large-scale structures, using the Horizon Run 5 cosmological hydrodynamical simulation. We identify LAEs using the Lyα emission line luminosity and its equivalent width, and LBGs using the broadband magnitudes at z ∼ 2.4, 3.1, and 4.5. We first compare the spatial distributions of LAEs, LBGs, all galaxies, and dark matter around the filamentary structures defined by dark matter. The comparison shows that both LAEs and LBGs are more concentrated toward the dark matter filaments than dark matter. We also find an empirical fitting formula for the vertical density profile of filaments as a binomial power-law relation of the distance to the filaments. We then compare the spatial distributions of the samples around the filaments defined by themselves. LAEs and LBGs are again more concentrated toward their filaments than dark matter. We also find the overall consistency between filamentary structures defined by LAEs, LBGs, and dark matter, with the median spatial offsets that are smaller than the mean separation of the sample. These results support the idea that the LAEs and LBGs could be good tracers of large-scale structures of dark matter at high redshifts.