1

I'm not sure how to title this question so feel free to change it.

Given the following:

enter image description here

This does look like what I think I want, however, notice that I "eyeballed" the leftmargin passed to the itemize list. In this case it seems like 45pt is what gets it to line up (maybe I'm wrong).

What I'm wondering is if there's some way this can be computed (or if there's another way to do it altogether) so that I don't have to hardcode it, so that it would automatically work regardless of the document margins.

Note that \parindent is 0pt, which is indeed how I want it.

\documentclass[10pt]{article}

\usepackage{fontspec}
\usepackage[inline]{enumitem}
\usepackage[letterpaper,vmargin=0.3in,hmargin=0.7in]{geometry}

\defaultfontfeatures{Ligatures=TeX}
\setmainfont{TeX Gyre Pagella}

\setlength{\parindent}{0pt}
\pagestyle{empty}

\newlist{points}{itemize}{1}
\setlist[points]{label=»,leftmargin=0pt,itemsep=2pt,parsep=0pt,topsep=4pt}

\begin{document}

I want the left-most edge of the list contents below (the labels in particular) to be aligned with this text.

\begin{points}[leftmargin=45pt] % What should leftmargin be so that it's not hardcoded?
  \item[{\textbf{ABC 1}} »] This is a line to illustrate the problem it is long enough to somewhat reach the end
  \item[{\footnotesize Abc 1234} »] This is a second line to illustrate the problem it is long enough to somewhat reach the end
  
  \par\addvspace{\baselineskip}
  
  \item[{\textbf{ABC 2}} »] This is a third line to illustrate the problem it is long enough to somewhat reach the end
  \item[{\footnotesize Abc 5678} »] This is a fourth line to illustrate the problem it is long enough to go past the end and wrap onto another line at this point. It should wrap like this, with an indent skipping the label's width.
  \item Final point for good measure.
\end{points}\par

I want the left-most edge of the list contents above (the labels in particular) to be aligned with this text.

\end{document}

1 Answer 1

1

Specify the widest element in the list and recalculate the leftmargin by using the * option:

enter image description here

\documentclass{article}

\usepackage{fontspec}
\usepackage[inline]{enumitem}
\usepackage[letterpaper,vmargin=0.3in,hmargin=0.7in]{geometry}

\defaultfontfeatures{Ligatures=TeX}
\setmainfont{TeX Gyre Pagella}

\setlength{\parindent}{0pt}
\pagestyle{empty}

\newlist{points}{itemize}{1}
\setlist[points]{label=»,leftmargin=0pt,itemsep=2pt,parsep=0pt,topsep=4pt}

\begin{document}

I want the left-most edge of the list contents below (the labels in particular) to be aligned with this text.

\begin{points}[widest={{\footnotesize Abc 1234} »},leftmargin=*]
  \item[{\textbf{ABC 1}} »] This is a line to illustrate the problem it is long enough to somewhat reach the end
  \item[{\footnotesize Abc 1234} »] This is a second line to illustrate the problem it is long enough to somewhat reach the end
  
  \par\addvspace{\baselineskip}
  
  \item[{\textbf{ABC 2}} »] This is a third line to illustrate the problem it is long enough to somewhat reach the end
  \item[{\footnotesize Abc 5678} »] This is a fourth line to illustrate the problem it is long enough to go past the end and wrap onto another line at this point. It should wrap like this, with an indent skipping the label's width.
  \item Final point for good measure.
\end{points}\par

I want the left-most edge of the list contents above (the labels in particular) to be aligned with this text.

\end{document}
1
  • Thank you Werner! So I guess the trick is to eyeball what the widest label is and use that to compute the distance. I think that'll do, certainly better than hardcoding a number. Commented May 8, 2021 at 21:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .