我想在我的文档中添加以下边注:
我怎样才能在我的笔记上方和下方添加如图所示的灰线?此外,我的边注被完全截断了:
我正在使用文档类书籍,以及以下命令:
\documentclass[a4paper]{book}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{cite}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{subfigure}
\usepackage{listings}
\usepackage{framed}
\usepackage{multicol}
\usepackage{color}
\usepackage{graphics}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{caption}
\usepackage{comment}
\usepackage{hyperref}
\usepackage[english]{babel}
\usepackage{makecell}
\usepackage[left=3.5cm]{geometry}
\usepackage{capt-of}
\usepackage{algorithm2e}
\usepackage{wrapfig}
\usepackage{floatflt}
\usepackage{acro}
\usepackage[acronym]{glossaries}
\usepackage[refpage]{nomencl}
\usepackage{blindtext}
\usepackage[most]{tcolorbox}
\usepackage{graphicx}
\setlength\parindent{0ex}
\graphicspath{ {figures/} }
\usepackage{titlesec}
\usepackage{marginnote}
%\usepackage[dvipsnames]{xcolor}
\definecolor{test}{RGB}{138,0,43}
\titleformat{\section}
{\color{test}\normalfont\Large\bfseries}
{\color{test}\thesection}{1em}{}
\title{Draft }
\author{test}
\raggedbottom
\begin{document}
\maketitle
\chapter{Introduction}
\section{Introduction}
\label{sec:intro}
Test test
\marginpar{{\color{brown}BOLD} This is a margin note
using the geometry package, set at
3cm vertical offset to the line it is typeseted.}
\end{document}
答案1
包括\rule
s 在您的\marginpar
:
\documentclass[]{article}
\usepackage{duckuments}
\usepackage{xcolor}
\newcommand\marginrule{\textcolor{gray}{\rule{\marginparwidth}{.4pt}}}
\newcommand\mymarginpar[1]
{%
\marginpar{\marginrule\\#1\\[-0.5\baselineskip]\marginrule}%
}
\begin{document}
\blindduck[1]
\mymarginpar{Ducks are awesome, but rabbits are better}%
\blindduck[2]
\end{document}
\toprule
使用包\bottomrule
的替代版本booktabs
代替自定义规则:
\documentclass[]{article}
\usepackage{duckuments}
\usepackage[table]{xcolor}
\usepackage{booktabs}
\newcommand\mymarginpar[1]
{{%
\arrayrulecolor{gray}%
\marginpar{\begin{tabular}[t]{@{}p{\marginparwidth}@{}}\toprule
#1\\\bottomrule\end{tabular}}%
}}
\begin{document}
\blindduck[1]
\mymarginpar{Ducks are awesome, but rabbits are better}%
\blindduck[2]
\end{document}
设置包括geometry
:
\marginparwidth=4cm % change this to your liking
\usepackage
[inner=3.5cm,outer=\dimexpr\marginparwidth+2\marginparsep\relax]
{geometry}
它根据您的计算外边距\marginparwidth
。考虑一下,行宽超过 80 个字符(这里没有固定值,取决于基线跳过和字体大小)会使文档更难阅读。(以上结果是每行大约 88.6 个字符)。