如何自定义边注选项以避免在切换边注位置时超出页面边框?

如何自定义边注选项以避免在切换边注位置时超出页面边框?

我正在使用\marginnote命令在正文的左右两侧插入注释。边注的默认位置是较大的边距,但可以使用 进行切换\reversemarginpar。但是,当切换发生时,LaTeX 甚至marginnote包都不会自动处理左右边距的差异,这会导致较小边距上的边注超出页面边框。

以下两张图片可以说明我所说的内容:

在此处输入图片描述

在此处输入图片描述

请注意,我截取了整个页面宽度的屏幕截图,因此我没有裁剪图像。问题是:是否有序言宏(或新命令)可以帮助在将边注切换到边距较小的一侧时自动处理边距差异?此外,边注文本的对齐方式也应相应改变,即,如果边注文本的对齐方式最初是左对齐,则在使用\reversemarginpar命令时应自动将其切换为右对齐,反之亦然。

这是我的 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}

答案1

\marginparsep也在页面边缘添加了一个间隙。

\documentclass[11pt, a4paper]{book}
\dimen0=\dimexpr 1in+\oddsidemargin-2\marginparsep\relax
\ifdim\marginparwidth>\dimen0 \marginparwidth=\dimen0\fi
\dimen0=\dimexpr \paperwidth-\textwidth-1in-\oddsidemargin-2\marginparsep\relax
\ifdim\marginparwidth>\dimen0 \marparginwidth=\dimen0\fi
\dimen0=\dimexpr 1in+\evensidemargin-2\marginparsep\relax
\ifdim\marginparwidth>\dimen0 \marparginwidth=\dimen0\fi
\dimen0=\dimexpr \paperwidth-\textwidth-1in-\evensidemargin-2\marginparsep\relax
\ifdim\marginparwidth>\dimen0 \marginparwidth=\dimen0\fi

\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}

相关内容