\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage{microtype}
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage{enumitem}
\usepackage{listings}
\usepackage{smartnotes}

\hypersetup{colorlinks=true,linkcolor=blue,urlcolor=blue}
\lstset{
  basicstyle=\ttfamily\small,
  columns=fullflexible,
  keepspaces=true,
  frame=single,
  breaklines=true
}



\title{smartnotes \\ \small A package for dynamic side notes}
\author{Author: \textit{Abhishek Ranna}}
\date{Version 0.1 \texttt{2026/04/05}}

\begin{document}
\maketitle

\section{Overview}

\texttt{smartnotes} provides margin notes that automatically choose the left or right margin based on the note position, so connector lines remain short and direct. Its main focus is clear visual anchoring of notes using short connector arrows. It also supports forced side placement, basic overlap avoidance and two box styles.\footnote{This package exists because I was supposed to be writing something important, but a minor formatting frustration turned into an evening of procrastination and, eventually, a package.} 
It is intended for drafting—hence the convenient global disable option—and for adding notes to yourself or collaborators while preparing a document.
\par


\section{Loading the package}

\begin{lstlisting}
\usepackage{smartnotes}
\end{lstlisting}

To disable all notes without having to remove them:

\begin{lstlisting}
\usepackage[disable]{smartnotes}
\end{lstlisting}

\section{Default settings}

The default values \footnote{These defaults do not have any specific logic; they are simply the ones I was trying to achieve on the evening this package was written.} used by \texttt{smartnotes} are listed in Table~\ref{tab:smartnotes-defaults}.

\begin{table}[h]
\centering
\begin{tabular}{ll}
\hline
\textbf{Option} & \textbf{Default value} \\
\hline
\texttt{width} & \texttt{2.2cm} \\
\texttt{sep} & \texttt{8pt} \\
\texttt{pagepad} & \texttt{6pt} \\
\texttt{stacksep} & \texttt{6pt} \\
\texttt{cornerradius} & \texttt{4pt} \\
\texttt{backgroundcolor} & \texttt{cyan!20} \\
\texttt{bordercolor} & \texttt{black} \\
\texttt{textcolor} & \texttt{black} \\
\texttt{linecolor} & \texttt{blue} \\
\texttt{font} & \verb|\footnotesize\sffamily| \\
\texttt{shape} & \texttt{rounded} \\
\texttt{side} & \texttt{auto} \\
\texttt{fancyline} & enabled \\
\hline
\end{tabular}
\caption{Default settings of the \texttt{smartnotes} package.}
\label{tab:smartnotes-defaults}
\end{table}

In words, the defaults correspond to a rounded note box of width \texttt{2.2\,cm}, separated
from the text area by \texttt{8\,pt}, with a page-edge padding of \texttt{6\,pt} and a
vertical stacking separation of \texttt{6\,pt}. The default corner radius is
\texttt{4\,pt}. The note box uses a \texttt{cyan!20} background with a black border and
black text, while connector lines are drawn in blue. The default font is
\verb|\footnotesize\sffamily|. Notes are placed automatically on the left or right margin
according to their position in the text area, and fancy connector lines are enabled by default. 

\section{Global setup}

Use \verb|\notesetup| in the preamble if you wish to make changes to default style:

\begin{lstlisting}
\notesetup{
  width=2.2cm,
  sep=8pt,
  pagepad=6pt,
  stacksep=4pt,
  backgroundcolor=yellow!30,
  bordercolor=black,
  textcolor=black,
  linecolor=black,
  fancyline,
  rounded,
  cornerradius=4pt,
  font={\linespread{0.7}\selectfont\footnotesize\itshape\sffamily}
}
\end{lstlisting}

\section{The \texttt{\textbackslash note} command}

\begin{lstlisting}
\note{Automatic side note}
\note[left]{Forced left}
\note[right]{Forced right}
\note[rectangle]{Sharp corners}
\note[rounded,cornerradius=6pt]{Rounded box with modified corener radius}
\note[nofancyline]{No connector, can be used as a comment box.}
\end{lstlisting}

\section{Supported options}

\begin{itemize}[leftmargin=2.2em]
  \item Dimensions: \verb|width|, \verb|sep|, \verb|pagepad|, \verb|stacksep|, \verb|cornerradius|
  \item Colors: \verb|backgroundcolor|, \verb|bordercolor|, \verb|textcolor|, \verb|linecolor|, \verb|color|
  \item Side selection: \verb|auto|, \verb|left|, \verb|right|
  \item Shape: \verb|rectangle|, \verb|rounded|
  \item Connector: \verb|fancyline|, \verb|nofancyline|
  \item Font: \verb|font={...}|
\end{itemize}

\newpage
\section{Example}

%Modify the styling here as shown to change it globally from the default

% \notesetup{
%   width=2cm,
%   sep=8pt,
%   pagepad=6pt,
%   stacksep=4pt,
%   backgroundcolor=cyan!30,
%   bordercolor=black,
%   textcolor=black,
%   linecolor=black,
%   rounded,
%   cornerradius=4pt,
%   font={\linespread{0.7}\selectfont\footnotesize\itshape\sffamily}
% }
\
The line starts here\note{Note goes here} and the connector shows the location for the note.\par
\medskip
For a note that needs to be on the end of a line it shall go here\note{Note B} and automatically be printed on the nearest margin.\par
\medskip
A sentence with a note\note{Automatic placement and stacking.} and another\note{Second note on the same line.}.

\vspace{2cm}
If for some reason you want\note[right]{Forced placement} a note on the far side - then you can force it like here.

\end{document}
