10

I want to mark certain points in my text by adding a marker 0.5cm outside the left margin of the text (at the hight of the point that is to be marked out).

The marker is drawn with tikz but could in princilpe be anything, such as an asterisk.

How can this be done without influencing the text in any way?

Eg:

This is a part of my long text.  In it 
there is something interesting \mark that 
should be easy to find by locating the 
marker to the left of the text. 

This should produce something like this:

※ This is a part of my long text. In it there is something interesting that should be easy to find by locating the marker to the left of the text.

(imagine that ※ is outside the left margin and that the text flows as if nothing had happened)

user25750
  • 185
  • You always want it on the left margin? No change between even and odd pages? – Count Zero Jul 10 '13 at 10:50
  • Actually, for this purpose, I only want the marker in the left margin. For completeness, an answer probably should address the two sided problem, though. Are the solutions to the two problems very different? – user25750 Jul 10 '13 at 10:57

2 Answers2

12

Here's a solution that doesn't use any extra package and doesn't abuse \marginpar:

\documentclass{article}
\newcommand{\impmark}{\strut\vadjust{\domark}}
\newcommand{\domark}{%
  \vbox to 0pt{
    \kern-\dp\strutbox
    \hbox{\smash{\llap{*\kern1em}}}
    \vss
  }%
}

\begin{document}

This is a paragraph with something \impmark important bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla and something \impmark else.

\end{document}

enter image description here

egreg
  • 1,121,712
  • This solution is excellent, and in fact the best I have seen for answering the question [http://tex.stackexchange.com/questions/347970/placing-phantomsection-in-the-margin/]. However, it does not work inside the optional argument of an \item. Is there a way to overcome that? – Thomas Colcombet Jan 16 '17 at 10:12
  • @ThomasColcombet There are questions about placing some symbol at the left of an \item label. – egreg Jan 16 '17 at 10:14
  • @egreg I just tried this MWE, and this is the output I get. Perhaps something has changed in the latex kernel since 2017? I compiled it on a tex distribution from 2017 and it gives the desired output, but not on a newer one. – tush Dec 21 '22 at 22:49
  • @tush Yes, something has changed in the meantime. Fixed the code. – egreg Dec 21 '22 at 23:01
4

A simple answer to this would be:

\documentclass{article}

\usepackage{lipsum}

\newcommand{\markme}{\marginpar[*]{}}

\begin{document}
\reversemarginpar
\lipsum[1-3]\markme

\lipsum[1-3]\markme
\end{document}

Which gives the desired result. By default \marginpar is creating a margin note on the right side, hence the need for \reversemarginpar. If you want alternating sides, just use \newcommand{\markme}{\marginpar[*]{*}}. Be aware though, that this works only with twosided documents. Another problem you may run into is if you try to use \marginpar with some kinds of special contents, e.g. equations or footnotes. Also, some document classes (e.g. memoir or tufte) have special mechanisms to handle margin notes (and notes in general).

Since I don't know what your exact use case is, I'm just going to give a few pointers if you experience difficulties: take a look at the marginnote, the mparhack and--if you fancy something more colorful--the todonotes packages.

EDIT: To adjust the distance of the margin note from the text it is a bit tricky. You will need to use the geometrypackage. It will need an argument called marginparsep, like this:

\usepackage[marginparsep=-1.8cm]{geometry}

This is not the actual dimension you want to set, rather the distance of the margin note from the edge of the page, so you can 'push' the margin note into the text. The value of it will be most likely negative. More on how to calculate it: here. Anyway, to get it straight, some experimentation will be required.

Count Zero
  • 17,424