57

Here is my very unsatisfactory attempt at this, but perhaps someone can use this to come up with a real solution. This just requires way too much tweaking of the paramaters to control the location of the comment text. References: The only good part of this is from percusse's answer at Simulating hand-drawn lines. Further Enhancements: Replace font of ...


36

This probably isn't as robust as it could be as it's only tested on this one page but it shows a mechanism (relying on pdftex \pdfsavepos in this version) that automatically moves notes up at the end of (explicit) paragraphs, and shrinks the inter-note space as needed to avoid the notes falling off the page. In this version it never splits a note over a page,...


34

Updates: These will be removed later. Adding here now while this is being developed/tested. 2012-11-23: Added \AtEndDocument hook to add a phantom para at the end of the document. This corrects issue noticed during development where the margin par at the bottom of the last paragraph was not able to automatically shift itself up. Here is a version that ...


22

You cannot change the margin for side notes within the same paragraph. Therefore you can wait until the next paragraph to do that, or use \marginnote (found in the marginnote package) instead of \marginpar. In this way, even the same note can write different texts depending on which margin appear: \documentclass{article} \usepackage{xcolor} \usepackage{...


21

Here's one possible solution patching (with the help of the etoolbox package) the LaTeX kernel command \@addmarginpar: \documentclass[twoside]{book} \usepackage[centering,marginparwidth=2.5cm]{geometry} \usepackage{etoolbox} \usepackage{lipsum} \makeatletter \patchcmd{\@addmarginpar}{\ifodd\c@page}{\ifodd\c@page\@tempcnta\m@ne}{}{} \makeatother \...


20

The following code adds the rule only on pages with marginpars. If they appear on both sides (using a mix of \reversemarginpar and \normalmarginpar) the rules show up on both sides. Customization possibilities are the rule itself (color, widths, etc) via \mparrule and the placement within the space given by \marginparsep via \mparrulefactor. \documentclass[...


19

You can use the etoolbox package to patch the \@mn@margintest command to set \if@tempswa to be always true and then issue a global \reversemarginpar: \documentclass[twoside]{book} \usepackage[centering,marginparwidth=2.5cm,paperheight=10cm]{geometry} \usepackage{marginnote} \usepackage{lipsum} \usepackage{etoolbox} \makeatletter \patchcmd{\@mn@margintest}{\...


17

You could use the tufte-latex package for this, which provides a marginfigure environment: \documentclass{tufte-handout} \usepackage{graphicx} \begin{document} \section{Rubber Ducks} \begin{marginfigure}[7.5ex] \includegraphics[width=\linewidth]{rubber_duck} \caption{A classic rubber duck} \end{marginfigure} A rubber duck is a toy shaped like a stylised ...


16

This solution deals with the asynchronous output routine: The pages are identified by absolute page numbers and the correct page numbers are available in the second LaTeX run using labels. Each page get two collector boxes that collect the marginal notes for the top and the bottom. At shipout time the absolute page number is known and the collector boxes ...


15

You could use the marginnote package and use its \marginnote command. \marginnote is a non-floating version of \marginpar and can also be used inside the align environment: \documentclass{article} \usepackage{amsmath} \usepackage{marginnote} \begin{document} \begin{align} E^2 \marginnote{Not correct} \end{align} \end{document}


14

It takes two runs for the margin notes to show up. I put the content as well as the location into the aux file so that I didn't have to synch two different sources. I used \marginparpush to separate consecutive margin notes vertically. I added \marginfillstyle to set the font etc. \documentclass{article} \usepackage{everypage} \usepackage{amsmath} \...


14

You can build up on this: \documentclass{article} \newcommand{\?}{\multicolumn{1}{c|}{\scriptsize0}} \begin{document} \begin{tabular}{cccccc|r} \? & \? & \? & \? & \? & 0 & 0 \\ \? & \? & \? & \? & \? & 1 & 1 \\ \cline{6-6} \? & \? & \? & \? & 1 & 0 & 2 \\ \? & \? & \? & \? ...


12

I'm not sure if LyX exposes them, but the Tufte-LaTeX document classes provide a few options for adjusting the positions of captions and margin notes. Adjusting margin notes and sidenotes positions First, if you want to adjust the minimum distance between all margin notes (and not just one or two), then you can set the \marginparpush length: % The default ...


12

There is one limited time when you can get marginpars on both sides. If you are at the end of a paragraph in which you already placed a marginpar, you can \par\vspace{-\parskip}, reverse the marginpar direction and do a marginpar on the other side. With this particular implementation, I also allow some vertical shifting to the note, with my routine \mnote[...


12

One option using \tikzmark (since some calculations are performed for the bar placement, the code needs three runs to stabilize). The bar admits (multiple) page breaks: \documentclass{article} \usepackage[a5paper,rmargin=4cm]{geometry} \usepackage{atbegshi} \usepackage{refcount} \usepackage{setspace} \usepackage{tikzpagenodes} \usetikzlibrary{calc} \...


11

If lines don't have unusual depth, this could be a starting point: \input eplain \leftmargin=2in \font\mainfont=pxr at 10pt \font\sidenotefont=pxi at 8.5pt \long\def\sidenote#1{% \vadjust{\llap{\smash{\vtop{% \parindent=0pt \hsize=1.7in \parfillskip=0pt \leftskip=0pt plus1fil \baselineskip=10pt\sidenotefont\vglue-\ht\strutbox #1}}\...


10

The figure number is stepped every time twice, because you're typesetting the caption twice. You can avoid this by typesetting it only once: \newcommand{\fixedmarginpar}[2][0pt]{% \setbox0=\vtop{\parindent=0pt \hsize=\marginparwidth#2}% \marginpar{\vspace{\dimexpr-\ht0+#1}\box0 }% } In this way the box used for the measuring is not retypeset, but ...


10

The culprit appears to be the \FloatBarrier command (provided by the placeins package). If we remove the \FloatBarrier command from the code that generates the marginfigure, then no space is inserted: \documentclass{tufte-book} % Remove \FloatBarrier from marginfigure definition % to prevent unwanted spaces. \makeatletter% so we can use @ commands \...


10

Please always post compete documents not just fragments, your fragment if used at default article text width puts all three notes on the same line. So I had to experiment with widths to get the requested effect: \documentclass{article} \newcounter{xmarginpar} \newlength\xmarginparshift \setlength\textwidth{8cm} \makeatletter \def\xmarginpar#1{% \stepcounter{...


9

EDIT Original version using a newly allocated box register is at the end. This version uses the \footins insertion register to take advantage of the primitive insert capability to pick up the correct notes for each page. \documentclass[twoside]{article} \newcounter{f} \addtolength\textheight{-20\baselineskip} \def\z{\stepcounter{f}\Roman{f} \roman{f} \alph{...


9

Here is a solution adding a bar to all pages (unless specified otherwise). The bar is typeset as a background picture, with the package eso-pic, and drawn using tikz. There is probably an easier way to achieve it, but that way is convenient to adjust the lengths, etc. About lengths, you will see a good example of spaghetti code, showing that I don't know ...


9

The end of paragraph command (from \par or a blank line) attempts to remove any space at the end of the paragraph (before it does the linebreaking) by doing an \unskip operation. However the insert node for the marginpar protects the interword space so it doesn't get removed. If you are unlucky you get a linebreak and the last line of the paragraph only has ...


9

You can use LaTeX2e if you use a very new (2013/12/19) addition to the KOMA-Script family: the scrlayer-notecolumn package. It has a command \makenote{<note>} that per default adds a note to the margin. The package also allows to declare additional “notecolumns” where notes then can be added with \makenote[<name of notecolumn>]{<note>}. ...


9

Move the \marginpar inside the argument for \section: \documentclass[openany]{book} \begin{document} \chapter{Chapter Heading} \section[Section Heading]{Section Heading\protect\marginpar{\normalfont\normalsize Associated text}} Is it working? \end{document} As an alternative, you can use \marginnote from the marginnote package instead and move the \...


9

Add the following lines in your preamble: \makeatletter \let\oldmarginnote\marginnote \renewcommand*{\marginnote}[1]{% \begingroup% \ifodd\value{page} \if@firstcolumn\reversemarginpar\fi \else \if@firstcolumn\else\reversemarginpar\fi \fi \oldmarginnote{#1}% \endgroup% } \makeatother MWE: \documentclass[twoside]{article} \...


9

The width of a marginpar is \marginparwidth separated from the text block by \marginparsep. Any code that is changing the margins should ensure that the sum of these fits in the margin space. fullpage doesn't bother, presumably because the intention there is to make the text block full width so that essentially there are no margins wide enough for text. ...


9

Add \leavevmode so the paragraph will be started anyhow. \documentclass[a4paper,11pt]{scrartcl} \usepackage[utf8]{inputenc} \newcommand{\introduce}[1]{% \leavevmode % if at the start of a paragraph \marginpar{#1}% the note \emph{#1}% the text } \begin{document} Bacon ipsum dolour sit amet porchetta beef turkey, bacon turducken boudin hamburger ...


8

The margins are set differently for odd/even pages. So you need to adjust \marginparwidth in order for the \marginpar to fit inside the inner margin: \documentclass[letter]{book} \renewcommand{\verse}[1]{\textsuperscript{#1}} \newcommand{\sidenote}[1]{% \sidenote{<side note>} \refstepcounter{sidenote}\mbox{\textsuperscript{\alph{sidenote}}}% \...


8

You hit a problem if there is ever a ] in the argument as then parsing for the optional argument goes wrong, so you need a {} group to hide the inner ]: \let\oldmarginpar\marginpar \renewcommand\marginpar[1]{\-\oldmarginpar[{\raggedleft\footnotesize\hspace{0pt}#1\par}]% {\raggedright\footnotesize\hspace{0pt}#1}}


Only top voted, non community-wiki answers of a minimum length are eligible