I want to do something similar to but not the same as line numbering:
A macro \foo is defined and a counter foocounter in an environment foonumber. When the macro is used, foocounter is increased by 1 and then printed on the left margin of the line where the macro is used. If more the macro is used than once on a line, all foocounter should be printed on the left margin, separated by a space.
This describes what I want to do, but I have no idea how I can print the counter on the left margin.
In addition, I am using multicol with two columns. I want the counter to be printed on the left side of each column. (In contrast, line numbering usually print the numbers on the outer margin.)
Addition made on 14 July 2014
I write a macro \foo in the following code. This seems successful, but the last occasion of the number jumps to the next page. The final page has no next page and the number disappears. Can anybody fix it?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\def\temppp{}
\newcounter{BAR}
\newcommand\foo{\stepcounter{BAR}$^{\arabic{BAR}}$\tikz[remember picture,overlay]\path let\p1=(current page.west),\p2=(X)in(\x1,0)coordinate(X)+(120pt,\y2)node[above left]{\ifdim\y2=0pt\global\edef\temppp{\temppp~\hbox{\arabic{BAR}}}\else\scriptsize\temppp\global\edef\temppp{\hbox{\arabic{BAR}}}\fi};}
\begin{document}
\hbox to 0pt{\tikz[remember picture]\node(X){};}%Put an X at the start
\foo Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \foo Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. \foo Curabitur dictum gravida mauris. \foo Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. \foo Donec vehicula augue eu neque. \foo Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. \foo Mauris ut leo. \foo Cras viverra metus rhoncus sem. \foo Nulla et lectus vestibulum urna fringilla ultrices. \foo Phasellus eu tellus sit amet tortor gravida placerat. \foo Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. \par
\vskip 360pt \foo Praesent eget sem vel leo ultrices bibendum. \foo Aenean faucibus. \foo Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. \foo Curabitur auctor semper nulla. \foo Donec varius orci eget risus. \foo Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. \foo Duis eget orci sit amet orci dignissim rutrum. \foo Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \foo Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. \foo Curabitur dictum gravida mauris. \foo Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. \foo Donec vehicula augue eu neque. \foo Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. \foo Mauris ut leo. \foo Cras viverra metus rhoncus sem. \foo Nulla et lectus vestibulum urna fringilla ultrices. \foo Phasellus eu tellus sit amet tortor gravida placerat. \foo Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. \par
\end{document}
\foohave to be used in thefoonumberenvironment? (Or: what happens if\foois used elsewhere?) – jon Apr 01 '14 at 03:59\fooin some environment. A possible reason to do it in this way is that we reset the counter whenever we begin the environment. – HYC Apr 01 '14 at 04:13