边注中的空格和 \newline 问题

边注中的空格和 \newline 问题
\documentclass[a4paper,11pt]{book}
\usepackage[left=1.5cm,right=1cm,top=3cm,bottom=1.5cm,marginparwidth=5.5cm,marginparsep=1cm,outer=8cm]{geometry}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[svgnames]{xcolor}
\usepackage{amssymb}
\usepackage[fulladjust]{marginnote}
\usepackage{ifoddpage}
\usepackage{showframe}

\newcommand{\arrow}[1]{%
\checkoddpage 
\ifoddpage
\marginnote{\hspace*{-.5\marginparsep}\makebox[0pt]{\textcolor{red}{$\blacktriangleleft$}}\hspace{.5\marginparsep}#1}
\else
\marginnote{\makebox[0pt][l]{\makebox[\dimexpr\marginparwidth+0.6\marginparsep\relax][r]%
{\textcolor{red}{$\blacktriangleright$}}}\hfill#1}
\fi 
}

\begin{document}

TEXT\arrow{\textbf High \textbf Frequency\newline \textbf Very \textbf High \textbf Frequency \newline \textbf Ultra \textbf High \textbf Frequency\newline \textbf Super \textbf High \textbf Frequency}

\newpage 
TEXT\arrow{\textbf High \textbf Frequency\newline \textbf Very \textbf High \textbf Frequency \newline \textbf Ultra \textbf High \textbf Frequency\newline \textbf Super \textbf High \textbf Frequency}

\end{document}

显示

在此处输入图片描述

奇数页没有问题。只有偶数页和添加\newline命令有空白。那么,有人知道如何修复它吗?

相关:\marginparsep 中间的边注有彩色标记

答案1

您必须将\\而不是\newline\raggedright或一起使用\raggedleft

我还简化了代码。

\documentclass[a4paper,11pt]{book}
\usepackage[
  left=1.5cm,
  right=1cm,
  top=3cm,
  bottom=1.5cm,
  marginparwidth=5.5cm,
  marginparsep=1cm,
  outer=8cm,
]{geometry}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[svgnames]{xcolor}
\usepackage{amssymb}
\usepackage[fulladjust]{marginnote}
\usepackage{ifoddpage}
\usepackage{showframe}

\newcommand{\printarrow}[2]{%
  \makebox[0pt][#1]{\makebox[\marginparsep]{\color{red}$#2$}}%
}

\newcommand{\arrow}[1]{%
  \checkoddpage 
  \ifoddpage
    \marginnote{%
      \printarrow{r}{\blacktriangleleft}%
      \parbox[t]{\marginparwidth}{\raggedright #1}%
    }%
  \else
    \marginnote{%
      \parbox[t]{\marginparwidth}{\raggedleft #1}%
      \printarrow{l}{\blacktriangleright}%
    }
  \fi 
}

\begin{document}

TEXT\arrow{\textbf{H}igh \textbf{F}requency\\
   \textbf{V}ery \textbf{H}igh \textbf{F}requency \\
   \textbf{U}ltra \textbf{H}igh \textbf{F}requency\\
   \textbf{S}uper \textbf{H}igh \textbf{F}requency}

\newpage 

TEXT\arrow{\textbf{H}igh \textbf{F}requency\\
   \textbf{V}ery \textbf{H}igh \textbf{F}requency\\
   \textbf{U}ltra \textbf{H}igh \textbf{F}requency\\
   \textbf{S}uper \textbf{H}igh \textbf{F}requency}

\end{document}

笔记。paperheight=8cm该示例只是为了在一张图片中显示两个页面而准备的。

在此处输入图片描述

答案2

我不太推荐这样做,因为它涉及使用 2 个边注,这似乎可能有危险,但这种方法可行:

\documentclass[a4paper,11pt]{book}
\usepackage[showframe,left=1.5cm,right=1cm,top=3cm,bottom=1.5cm,marginparwidth=5.5cm,marginparsep=1cm,outer=8cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[svgnames]{xcolor}
\usepackage{amssymb}
\usepackage[fulladjust]{marginnote}
\usepackage{ifoddpage}

\newcommand{\arrow}[1]{%
  \checkoddpage
  \ifoddpage
  \marginnote{\hspace*{-.5\marginparsep}\makebox[0pt]{\textcolor{red}{$\blacktriangleleft$}}\hspace*{.5\marginparsep}#1}%
  \else
  \marginnote{%
    \makebox[0pt]{\hspace*{.6\marginparsep}\textcolor{red}{$\blacktriangleleft$}}%
  }%
  \marginnote{#1}%
  \fi}

\begin{document}

  TEXT\arrow{%
    \textbf{H}igh \textbf{F}requency\\\textbf{V}ery \textbf{H}igh \textbf{F}requency \\\textbf{U}ltra \textbf{H}igh \textbf{F}requency\\\textbf{S}uper \textbf{H}igh \textbf{F}requency}

  \newpage
  TEXT\arrow{%
    \textbf{H}igh \textbf{F}requency\\\textbf{V}ery \textbf{H}igh \textbf{F}requency\\\textbf{U}ltra \textbf{H}igh \textbf{F}requency\\\textbf{S}uper \textbf{H}igh \textbf{F}requency}

\end{document}

页边空白处有被黑的注释

相关内容