I am using \marginnote command to insert notes to the left and right of the main text. The default location of the marginal note goes to the larger margin but can be switched with \reversemarginpar. However, when the switching happens, LaTeX, and even marginnote package, does not automatically handle the differences in left and right margins, which causes the margin notes on the smaller margin to exceed the page border.
Here are two images that illustrate what I am talking about:
Note that I took a screenshot for the whole width of the page so I did not crop the image. The question is: are there preamble macros (or new commands) that help automatically handle the differences in margins when switching margin note to the side with smaller margin? Also, the justification of the margin note text should change accordingly, that is, if the justification of the margin note text is originally left, it should be switched automatically to right when using \reversemarginpar command, and vice versa.
Here is my MWE:
\documentclass[11pt, a4paper]{book}
\usepackage{marginnote}
\begin{document}
\paragraph{Page with larger right margin}
This paper proposes an improved single-diode modeling approach for PV modules suitable for a broad range of the PV technologies available today, including modules on tandem cell structures. After establishing the model (which has an overall of seven parameters), the paper devises a methodology to estimate its parameters using Standard Test Conditions (STC) data, Nominal Operating Cell Temperature (NOCT) data, \marginnote[]{Right marginal notes work well} and temperature coefficients values as provided in most manufacturers' datasheets. Simulation results and their comparison with a previous work show a very accurate prediction of critical points in the current-voltage characteristics curve. The precise prediction happens for both STC and NOCT conditions and the error in predicting maximum power point lies within $1\%$ limit, and the error in its corresponding voltage and current is almost always within $2\%$ limit. Further, for both maximum power point\reversemarginpar \marginnote[But left marginal notes do not and may sometimes exceed page margins]{}[-1in] and open-circuit voltage, the statistical variance around manufacturer measurements due to temperature changes is demonstrated to be low for five various module technologies.
\newpage
\paragraph{Page with larger left margin}
This paper proposes an improved single-diode modeling approach for PV modules suitable for a broad range of the PV technologies available today, including modules on tandem cell structures. After establishing the model (which has an overall of seven parameters), the paper devises a methodology to estimate its parameters using Standard Test Conditions (STC) data, Nominal Operating Cell Temperature (NOCT) data, \reversemarginpar \marginnote[]{Right marginal notes do not work well and may sometimes exceed page margins} and temperature coefficients values as provided in most manufacturers' datasheets. Simulation results and their comparison with a previous work show a very accurate prediction of critical points in the current-voltage characteristics curve. The precise prediction happens for both STC and NOCT conditions and the error in predicting maximum power point lies within $1\%$ limit, and the error in its corresponding voltage and current is almost always within $2\%$ limit. Further, for both maximum power point\normalmarginpar\marginnote[But left marginal notes work well]{}[-1in] and open-circuit voltage, the statistical variance around manufacturer measurements due to temperature changes is demonstrated to be low for five various module technologies.
\end{document}


\marginparwidthfor each side can do that then yes. – Al-Motasem Aldaoudeyeh Mar 18 '18 at 02:13\marginparwidthsmall enough to fit on both sides, which depends on the page layout. – John Kormylo Mar 18 '18 at 16:18