如何在人工创建的边距中添加注释?

如何在人工创建的边距中添加注释?

我正在汇总用于记录康奈尔风格笔记的文档类。为此,我使用tcolorbox包并将它们排列成两列。terms左侧是与这些相关的列,右侧是notes这些相关的列。以下是一个例子:terms

布局示例

现在我想添加一种可能性,notes即在列中引入的“边距”中用文本突出显示某些部分term。像这样:

期望行为样本

以下是目前的全部课程:

\ProvidesClass{cornell}
\LoadClass[a4paper]{article}

\usepackage{tcolorbox}
\tcbuselibrary
{
    breakable,% Allows tcolorboxes to break across pages
    hooks,% Allows usage of hooks, like having an overlay only for the first part of a broken box
    skins,% Used to style the boxes with tikz
    xparse% Used to define document environments and commands
}

\usepackage[margin=2cm]{geometry} % Change geometry of pages
\usepackage[parfill]{parskip} % Modify parindent and parskip
\usepackage{enumitem} % Modify itemize spacing
\setitemize
{
    itemsep=0pt,
    parsep=2pt,
}

\usepackage{bookmark} % Add bookmarks to the resulting PDF
\usepackage{hyperref}
\hypersetup
{
    colorlinks   = true, % Colour links instead of ugly boxes
    urlcolor     = blue, % Colour for external hyperlinks
    linkcolor    = blue, % Colour of internal links
    citecolor    = red   % Colour of citations
}

\date{}

\tcbset
{
    colframe=black,
    colupper=black,
    opacitybacktitle=1,
    opacitytext=1,
    fonttitle=\large\bfseries\sffamily,
}

\NewTColorBox[]{titlebox}{ o }
{
    width=\textwidth,
    lowerbox=invisible,
    bookmark*={level=0}{\@title}
}

\renewcommand{\maketitle}
{
    \vspace{-3em}
    \begin{titlebox}
        \Huge{\sffamily{\@title}}
    \end{titlebox}
}

\NewTColorBox[]{extra}{ m }
{
    width=\textwidth,
    title=#1,
    bookmark*={rellevel=1}{#1},
}

\NewTColorBox[]{term}{ m }
{
    width=.325\textwidth,
}

% A note is a tcolorbox in the right column. It may be associated to a
% term which is provided as an optional argument. If a term is provided
% another left-aligned tcolorbox is created with a bookmark.
% It is also possible to give the note itself a title. In this case the
% note tcolorbox is given the provided title and a bookmark for this
% title is created.
\NewTColorBox[]{note}{ o d<> }
{
    enhanced,
    breakable,
    IfValueT={#1}{bookmark*={rellevel=1}{#1}},
    IfValueT={#2}{
        bookmark*={rellevel=2}{#2},
        title=#2,
    },
    enlarge left by=.34\textwidth,
    width=.66\textwidth,
    parbox=false,% restore main text formatting behavior
    overlay unbroken={
        \IfNoValueF{#1} {%
            \node[anchor=north west, outer sep=0pt, inner sep=0pt] at ([xshift=-.34\textwidth]frame.north west) {
                \begin{term}{#1}
                    #1
                \end{term}
            };
        }{}
    },
    overlay first app={
        \IfNoValueF{#1} {%
            \node[anchor=north west, outer sep=0pt, inner sep=0pt] at ([xshift=-.34\textwidth]frame.north west) {
                \begin{term}{#1}
                    #1
                \end{term}
            };
        }{}
    }
}

\NewDocumentEnvironment{summary}{}
{
    \vfill
    \begin{tcolorbox}[
        floatplacement=!b,
        float,
        title=Summary,
        bookmark*={level=1}{Summary},
        parbox=false,% restore main text formatting behavior
    ]
}
{
    \end{tcolorbox}
}

示例文件如下:

\documentclass{cornell}

\usepackage{lipsum}

\title{A topic we're taking notes on}

\begin{document}
\maketitle

\begin{extra}{Introduction}
    This can be used to introduce what is about to come, like
    \begin{enumerate}
        \item{What's the first question this section will answer?}
        \item{What's the second question?}
    \end{enumerate}
\end{extra}

\begin{note}[Some key term]
    \begin{itemize}
        \item{A cool thing}
        \item{Another cool thing}
        \item{Not all things are cool}
    \end{itemize}

    That has another paragraph.
\end{note}

\begin{note}<This is a titled noted with a very long title that should wrap around>
    \lipsum[10]
\end{note}

\begin{summary}
    A fabulous summary.

    With multiple paragraphs.
\end{summary}

\end{document}

答案1

可以将边距移到文本区域,从而产生所需的效果。详细信息请参见这里

这是重点部分:

\usepackage{geometry} % Change geometry of pages
\usepackage{marginnote} % Used to create notes in the margin
\renewcommand*{\raggedleftmarginnote}{} % Align notes to the left
\reversemarginpar
\geometry{
    margin=2cm,
    marginparsep=-.35\textwidth,
    marginparwidth=.325\textwidth,
}

结果如下: 结果

相关内容