使用 `marginnote` 环境缩小行距

使用 `marginnote` 环境缩小行距

我正在努力缩小环境中的行距marginnote​​。我可以在一个非常小的示例中做到这一点,但在我当前的完整用例中却做不到。对于某些人来说,我在完整示例中所做的事情是否明显覆盖了我的定义marginnote

按预期工作的最小示例:

\documentclass[justified,twoside,symmetric]{tufte-book}

\usepackage{url}
\usepackage{hyperref}
\usepackage{mparhack} 
\usepackage{parskip}

\definecolor{ghr-blue}{cmyk}{0.846, 0.234, 0.00, 0.212}
\definecolor{ghr-orange}{cmyk}{0.0, 0.37, 0.757, 0.098}
\hypersetup{colorlinks,linkcolor=,urlcolor=ghr-orange}

\usepackage{fontawesome5}
\usepackage{lipsum}

\AtBeginEnvironment{marginnote}{\linespread{0.5}}

\begin{document}


\lipsum[1]

\marginnote{\faIcon{book-reader} Some text here more text here making long \href{https://tinyurl.com/af98yyak}{\footnotesize\texttt{tinyurl.com/af98yyak}}}

\lipsum[2]

\end{document}

在此处输入图片描述

具有不需要的额外空间的实际用例:

{bookdown}(我用来创建 tex 文件的 R 包生成的一些命令)

\documentclass[justified,twoside,symmetric,]{tufte-book}

% ams
\usepackage{amssymb,amsmath}

\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
\else % if luatex or xelatex
  \makeatletter
  \@ifpackageloaded{fontspec}{}{\usepackage{fontspec}}
  \makeatother
  \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
  \makeatletter
  \@ifpackageloaded{soul}{
     \renewcommand\allcapsspacing[1]{{\addfontfeature{LetterSpace=15}#1}}
     \renewcommand\smallcapsspacing[1]{{\addfontfeature{LetterSpace=10}#1}}
   }{}
  \makeatother

\fi

% graphix
\usepackage{graphicx}
\setkeys{Gin}{width=\linewidth,totalheight=\textheight,keepaspectratio}

% booktabs
\usepackage{booktabs}

% url
\usepackage{url}

% hyperref
\usepackage{hyperref}

% units.
\usepackage{units}


\setcounter{secnumdepth}{2}

% citations
\usepackage{natbib}
\bibliographystyle{apalike-etal}


% pandoc syntax highlighting

% longtable
\usepackage{longtable,booktabs}

% multiplecol
\usepackage{multicol}

% strikeout
\usepackage[normalem]{ulem}

% morefloats
\usepackage{morefloats}


% tightlist macro required by pandoc >= 1.14
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

% title / author / date
\title{Global Health Research}
\author{Eric P. Green}
\date{2021-09-03}

\usepackage{booktabs}
\usepackage{mparhack} % https://tex.stackexchange.com/a/236380/30017
\usepackage{parskip}

% colors

\definecolor{ghr-blue}{cmyk}{0.846, 0.234, 0.00, 0.212}
\definecolor{ghr-orange}{cmyk}{0.0, 0.37, 0.757, 0.098}

\hypersetup{colorlinks,linkcolor=,urlcolor=ghr-orange}

% citations

\PassOptionsToPackage{round}{natbib}
\setcitestyle{super}
\renewcommand*{\citep}[1]{{\cite{#1}}}
\renewcommand*{\citet}[1]{{\cite{#1}}}

% icons

\usepackage{fontawesome5}

% break with tufte on subsubsections

\let\subsubsection\subsection

% fonts

\usepackage{fontspec}
\setmainfont{LibreBaskerville-Regular}
\setsansfont{SourceSansPro-Regular}
\setmonofont{Inconsolata}
\setsidenotefont{\fontspec{SourceSansPro-ExtraLight}[Scale=0.8]}
\setcaptionfont{\fontspec{SourceSansPro-ExtraLight}[Scale=0.8]}
\setmarginnotefont{\fontspec{SourceSansPro-ExtraLight}[Scale=0.8]}
\setcitationfont{\fontspec{SourceSansPro-ExtraLight}[Scale=0.8]\color{gray}}

% headers

\usepackage{fancyhdr}
\setlength{\headheight}{15pt}

\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{ \markboth{#1}{} }
\renewcommand{\sectionmark}[1]{ \markright{#1} }

\fancyhf{}
\fancyhead[LE]{\thepage\space\space\space$\cdotp$\space\space\space\chaptername\space\thechapter}
\fancyhead[RO]{\leftmark\space\space\space$\cdotp$\space\space\space\thepage}

\fancypagestyle{plain}{ %
  \fancyhf{} % remove everything
  \renewcommand{\headrulewidth}{0pt} % remove lines as well
  \renewcommand{\footrulewidth}{0pt}
}

% title page and level headings

\usepackage[svgnames]{xcolor}
\usepackage{titlesec}
\usepackage{xhfill}
\colorlet{rulecolor}{Gainsboro!40!Lavender}
\usepackage{lipsum}

\titleformat{\chapter}[display]
{\filcenter}{\mbox{}\xrfill[0.4ex]{3pt}[rulecolor]\bfseries\sffamily{\large\enspace\chaptername\space\thechapter}\enspace\xrfill[0.4ex]{3pt}[rulecolor]\mbox{}}{0.3ex} {{\color{rulecolor}\titlerule[1pt]}\vskip3ex\huge\bfseries\sffamily}[\medskip{\color{rulecolor}\titlerule[1pt]}]

\usepackage{titling}

\pretitle{\begin{flushleft}\huge\bfseries}
\posttitle{\par\end{flushleft}}

\preauthor{\begin{flushleft}\Large\bfseries}
\postauthor{\par\end{flushleft}}

\predate{\begin{flushleft}\large\mdseries}
\postdate{\par\end{flushleft}}

\titleformat*{\section}{\LARGE\bfseries\sffamily}
\titleformat*{\subsection}{\Large\bfseries\sffamily}
\usepackage[svgnames]{xcolor}

% table of contents

\usepackage{titletoc}

\contentsmargin[1cm]{0cm}
\titlecontents{chapter}[0em]{\vskip12pt\Large\bfseries\sffamily}
{\thecontentslabel\enspace}
{\hspace{1.05em}}
{ \hfill\contentspage}[\vskip 6pt]

\titlecontents{section}[1em]{\mdseries\sffamily}
{\thecontentslabel\enspace}
{}
{\titlerule*[1pc]{.}\quad\contentspage}[\vskip 4pt]

\titlecontents{subsection}[2.7em]{\mdseries\sffamily}
{\thecontentslabel\enspace}
{}
{\titlerule*[1pc]{.}\quad\contentspage}[\vskip 3pt]

\usepackage{etoolbox}
\pretocmd{\contentsname}{\sffamily}{}{}

% margins

% The default minimum amount of space between \marginnotes is 10 pt.
\setlength\marginparpush{15pt}

\AtBeginEnvironment{marginfigure}{\linespread{0.5}}
\AtBeginEnvironment{marginnote}{\linespread{0.5}}

\makeatletter
\renewcommand{\footnotelayout}{\@tufte@sidenote@font\@tufte@sidenote@justification\linespread{0.5}}
\makeatother


% Remove \FloatBarrier from marginfigure definition
% to prevent unwanted spaces.
\makeatletter% so we can use @ commands
\renewenvironment{@tufte@margin@float}[2][-1.2ex]{%
  %\FloatBarrier% removed because it adds unwanted white space
  \begin{lrbox}{\@tufte@margin@floatbox}%
  \begin{minipage}{\marginparwidth}%
    \@tufte@caption@font
    \def\@captype{#2}%
    \hbox{}\vspace*{#1}%
    \@tufte@caption@justification
    \@tufte@margin@par
    \noindent
}{%
  \end{minipage}%
  \end{lrbox}%
  \marginpar{\usebox{\@tufte@margin@floatbox}}%
}
\makeatother% restore meaning of @

% quote

\usepackage[most]{tcolorbox}

\newtcolorbox{newquote}[1][]{%
    colback=black!5,
    colframe=black!5,
    notitle,
    sharp corners,
    borderline west={2pt}{0pt}{ghr-blue!80!black},
    enhanced,
    breakable,
    }

\renewcommand{\quote}{\newquote}
\renewcommand{\endquote}{\endnewquote}


% margin note

\usepackage{booktabs}
\usepackage{longtable}
\usepackage{array}
\usepackage{multirow}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{colortbl}
\usepackage{pdflscape}
\usepackage{tabu}
\usepackage{threeparttable}
\usepackage{threeparttablex}
\usepackage[normalem]{ulem}
\usepackage{makecell}
\usepackage{xcolor}

\begin{document}

\lipsum[1]

\marginnote{\faIcon{book-reader} Some text here more text here making long \href{https://tinyurl.com/af98yyak}{\footnotesize\texttt{tinyurl.com/af98yyak}}}

\lipsum[2]

\end{document}

在此处输入图片描述

答案1

使用

\begin{marginfigure}
\faIcon{book-reader} Some text here more text here making long Some text here more text here making long Some text here more text here making long \href{https://tinyurl.com/af98yyak}{\footnotesize\texttt{tinyurl.com/af98yyak}}
\end{marginfigure}

或者添加到你的序言中

\makeatletter
\renewcommand\marginnote[2][0pt]{%
    \ifthenelse{\boolean{@tufte@loadnatbib}}{%
        \let\cite\@tufte@infootnote@cite%   use the in-sidenote \cite command
    }{}%
    \gdef\@tufte@citations{}%           clear out any old citations
    \marginpar{\hbox{}\vspace*{#1}\setstretch{0.5}\@tufte@marginnote@font\@tufte@marginnote@justification\@tufte@margin@par\vspace*{-1\baselineskip}\noindent #2}%
    \@tufte@print@citations%            print any citations
    \ifthenelse{\boolean{@tufte@loadnatbib}}{%
        \let\cite\@tufte@normal@cite%       go back to using normal in-text \cite command
    }{}%
}
\makeatother

使用 \marginnote{...}

C

相关内容