  The virial and the Hellmann--Feynman theorems for massless Dirac electrons in
a solid are derived and analyzed using generalized continuity equations and
scaling transformations. Boundary conditions imposed on the wave function in a
finite sample are shown to break the Hermiticity of the Hamiltonian resulting
in additional terms in the theorems in the forms of boundary integrals. The
thermodynamic pressure of the electron gas is shown to be composed of the
kinetic pressure, which is related to the boundary integral in the virial
theorem and arises due to electron reflections from the boundary, and the
anomalous pressure, which is specific for electrons in solids. Connections
between the kinetic pressure and the properties of the wave function on the
boundary are drawn. The general theorems are illustrated by examples of uniform
electron gas, and electrons in rectangular and circular graphene samples. The
analogous consideration for ordinary massive electrons is presented for
comparison.
