This is to ask a more general question: Landau-Lifshitz say that for the variational principles
$$\delta\int_{t_1}^{t_2}p\mathrm{d}q-H\mathrm{d}t =0$$$$ \delta\int_{t_1}^{t_2}P\mathrm{d}Q-H'\mathrm{d}t =0$$ to be equivalent, the difference $(p\mathrm{d}q-H\mathrm{d}t)-(P\mathrm{d}Q-H'\mathrm{d}t)$ must equal the differential of a certain function $F$ of $q,p$, and $t$. I would agree if $F$ were a function of $q$ and $t$ alone since the variational principles above are taken among $q,p$ such that $\delta q(t_i)=0$, $i=1,2$ so adding $\mathrm{d}F$ to the integrand adds a constant to the integral and the variational principle doesn't change. But in the case where it can depend on $p$ I don't see why. For instance in the case $Q=p$, $P=-q$, why would $\int_{t_1}^{t_2} \mathrm{d}(pq)$ be a constant?