0

I am struggling to shrink the line spacing with a marginnote environment. I can do it in a very minimal example, but not in my current full use case. Is it obvious to someone what I have in the full example that is overriding my definition of marginnote?

Minimal example that works as intended:

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

enter image description here

Actual use case with unwanted extra space:

(some commands generated by {bookdown} R package I'm using to create tex file)

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

enter image description here

  • 1
    It is not obvious to me. Try commenting out the packages in the full example until you get the result you want. That should indicate where the problem is. – Peter Wilson Sep 03 '21 at 16:39
  • Thanks for taking a look, @PeterWilson. My best guess at this point is that it's related to scaling down \setmarginnotefont{\fontspec{SourceSansPro-ExtraLight}[Scale=0.8]} but using a monospace font for the url in my sidenote that is not scaled (\setmonofont{Inconsolata}). – Eric Green Sep 03 '21 at 18:52
  • Editing to \setmonofont[Scale=0.8]{Inconsolata} does not solve the problem (and scales the font down everywhere, not just in the margin note). Neither does removing \texttt from the url (which I don't want to do anyway). Removing all reference to fontspec in the % fonts section works, but this takes away my desired styling. – Eric Green Sep 03 '21 at 19:28

1 Answers1

1

Use

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

Or add to your preamble

\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

to use \marginnote{...}

c

Simon Dispa
  • 39,141
  • Thanks, @simon-dispa. My tex file gets created by the bookdown package in R, and long story short, I'm using the function tufte::margin_note() to make this note. The output of the function is \marginnote{}. Is there a way to keep using \marginnote{} and get the desired result? – Eric Green Sep 03 '21 at 22:23
  • 1
    @Eric Green I updated the answer to be able to use marginnote. – Simon Dispa Sep 03 '21 at 22:31