4

I would like to place a tikz picture at the left margin location of the current line. Here is a MWE:

\documentclass{amsart}
\usepackage{tikz}

\begin{document}
\newcommand{\status}[1]{\tikz[overlay]{\node [left=3cm] {\bf#1};}}
    in (here)\status{??} the beginning of the line\\
    towards the middle of end of line (here)\status{?!}
\end{document}

which, as expected, produces

enter image description here

I know that there is at (current page.west) that I can use, but this doesn't seem to work (and isn't precisely what I want) and I couldn't find the correct fix in the documentation/elsewhere. Also, I know that there's a todos package which has similar functionallity but I really just need this simple bit only.

Thanks!

4

There's the tikzpagenodes package which offers current page text area anchors:

\documentclass{amsart}
\usepackage{tikzpagenodes}
\usepackage{showframe}
\usetikzlibrary{tikzmark}

\newcounter{tmp}
\newcommand\status[1]{%
  \stepcounter{tmp}%
  \tikzmark{start-\thetmp}%
  \tikz[remember picture,overlay,baseline=(sta.base)]
    {\node[anchor=east] at (current page text area.west|-{pic cs:start-\thetmp})
    (sta) {\textbf{#1}};}%
}
\begin{document}

test\status{ready!}

test\status{to do!}

\end{document}

enter image description here

Without tikzpagenodes you need to anchor at the x-coordinate of current page westand then shift by an amount \oddsidemargin+\hoffset+1in:

\documentclass{amsart}
\usepackage{showframe}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc}

\newcounter{tmp}
\newcommand\status[1]{%
  \stepcounter{tmp}%
  \tikzmark{start-\thetmp}%
  \tikz[remember picture,overlay,baseline=(sta.base)]
    {\node[anchor=east] at 
    ( $ (current page.west|-{pic cs:start-\thetmp}) + (\oddsidemargin+\hoffset+1in,0) $ )
    (sta) {\textbf{#1}};}%
}
\begin{document}

test\status{ready!}

test\status{to do!}

\end{document}
  • not as simple as wanted (hoped tikz would provide (page.west+document.margin,current.y)) or something like that but this certainly does what I want, so thanks! – r0fg1 Feb 24 '15 at 17:27
  • @r0fg1 You're welcome! I updated my answer with an option not involving tikzpagenodes. – Gonzalo Medina Feb 24 '15 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.