Using a box technique (Paragraph numbers at left margin), I added margin text.
I'd like the top of the left-aligned number to be flush with the top of the paragraph text rather than having the baselines aligned.
I am hoping to learn a box trick here. (I can do this with tikz, but I'd like to learn how to do it with TeX or LaTeX boxes) I tried adding a third \makebox[0pt][t]{1.} but I could not get it to align as desired. Is minipage the only/best way? My skills got a little weak after the Christmas vacation :=)
Code
\documentclass{article}
\usepackage{fontspec}% xelatex
\usepackage{lipsum}
\setlength{\parindent}{0mm}
\newcommand{\marginnum}[1]{\makebox[0mm][r]{\makebox[12mm][l]{\Huge\bfseries #1.}}}
\begin{document}
\marginnum{1}\lipsum[1]
\end{document}
Output
Desired Output using TikZ
Using a similar \makebox of zero-width technique, I create an inline node on the first line of the paragraph. I then anchor a second node to the top of that node containing my margin text.
\documentclass{article}
\usepackage{fontspec}% xelatex
\usepackage{lipsum}
\usepackage{tikz}\usetikzlibrary{calc}
\setlength{\parindent}{0mm}
\newcommand{\marginnum}[1]{%
\makebox[0pt][r]{%
\begin{tikzpicture}[remember picture]%
\node [inner sep=0pt,outer sep=0pt] (parstart) {\phantom{L}};%
\end{tikzpicture}}%
\begin{tikzpicture}[remember picture, overlay]%
\node [inner sep=0pt,outer sep=0pt,anchor=north east,font=\bfseries\Huge] at ($ (parstart.north west)+(-12mm,0) $) {#1.};%
\end{tikzpicture}%
}%
\begin{document}
\marginnum{1}\lipsum[1]
\end{document}





\ignorespaceshere? I seem to be having a space issue (in my actual document, not my minimal example) – Jonathan Komar Jan 05 '17 at 06:05\marginnumon a line by itself – egreg Jan 05 '17 at 09:59\marginnumwidthdynamic is more robust. For future reference, you did it here: http://tex.stackexchange.com/questions/312581/how-to-calculate-width-of-remaining-part-of-line – Jonathan Komar Feb 13 '17 at 21:13