Initially, I had the code

|a_d|_p & = 1 \\
|a_i|_p & \leq 1

which produced the result below:

first image

This is undesirable because the vertical bars | on the left don't line up. Then I discovered the alignat environment, and tried the code

| & a_d & |_p & & & = 1 \\
| & a_i & |_p & & & \leq 1

which produced the result below:

second image

This is better, but it's still not great because now the a_d and a_i don't line up. Ideally, I'd want just the column with the a_d and a_i to be centered. Then, I looked at the answer to this question, and tried the code

| & \omit\hfill $a_d$ \hfill & |_p & & & = 1 \\
| & \omit\hfill $a_i$ \hfill & |_p & & & \leq 1

which produced the result below:

third image

This is better in some respects because each of the vertical bars line up, as do the a_d and a_i, but now the right-hand vertical bars |_p are spaced too far to the right. Any suggestions?

UPDATE: After reading the code in Bernard's suggestions, along with some information about \makemathbox (from mathtools), \newlength, and \settowidth, I came up with the following code, which seems to do what I want. However, am I doing anything that is deprecated?


|a_d|_p & = 1 \\
| \mathmakebox[\myl]{a_i} |_p & \leq 1
  • 2
    an experienced math copyeditor wouldn't find the original presentation inappropriate. i think this is a case of "trying too hard". Commented Jul 2, 2015 at 18:09

1 Answer 1


Here are two solutions, using mathtools, and makebox for one of them. For the second one , with eqparbox , more automated. I define a \varpabs command which uses a tag: all \varpabs which share the same tag will have the same width – that of the widest argument:


\usepackage{makebox, eqparbox}
\DeclarePairedDelimiterXPP{\pabs}[1]{}\lvert \rvert{_p}{\ifblank{#1}{\:\cdot\:}{#1}}


  \pabs{a_d} & = 1 \\
  \pabs{\makebox*{$ a_d $}{$ a_i $}} & \leq 1

  \varpabs{A}{a_d + c} & = 1 \\
  \varpabs*{A}{ \frac{a_i }{b_i}} & \leq 1


enter image description here

  • Also, how does the code I just added to the bottom of my question look?
    – justin
    Commented Jul 3, 2015 at 3:08
  • @justin You should read barbara's comment on your question: she knows whereof she speaks. (At least, if anybody here knows, she does. Conversely, if she doesn't know, we're all whistling in the dark.)
    – cfr
    Commented Jul 3, 2015 at 3:16
  • @cfr I appreciate it... I saw her comment, and while it's reassuring to know I could have left everything as is, I'm also curious about how I can manipulate LaTeX spacing in general, so that's why I'm spending energy on this. Working on this particular task is kind of an instructive example for me.
    – justin
    Commented Jul 3, 2015 at 3:24

You must log in to answer this question.

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