0

I am currently having issues with vertial alignment based on the type of character being inputted. If I use a character that has some sort of descender or tail, it adjusts the height of the \hrule that appears under the text. This can be seen in the image below, in which the p of pppaaa is shifting the \hrule.

Sample Text

To create this, I am using a small custom command which is the following

\newcommand{\customHeading}[1] {
    \begin{flushleft}
        \LARGE{#1}
    \end{flushleft}
    \hrule height 1.5pt
}

Now, I could just use a \vspace{...}, in which I pass a custom spacing parameter for each new \customHeading but that seems a tad hacky. I was hoping there would be a better way of adjusting the alignment, in which I am open to suggestions!

Note - I looked at the following question, but using those ideas, I couldn't really fix my issue.

6
  • 1
    Hi and welcome. Maybe a \strut can help?
    – mickep
    Feb 15 at 18:37
  • I tried that and it didn't seem to have much affect. The descender still shifted the \hrule
    – Andy
    Feb 15 at 18:45
  • 1
    A strut would be bigger than the descender of p so both lines would be the same,or you could use latex \rule instead of the tex prmitive \hrule then the spacing would be the same. Feb 15 at 20:10
  • 1
    unrelated but \LARGE{#1} should be \LARGE#1 size commands do not take an argument. Feb 15 at 20:24
  • 1
    Since there's plenty of room below the text, you probably want to ignore the descender, Try \smash[b]{...}. If the text extends to more than one line, apply the \smash to only the last line. Feb 15 at 20:25

1 Answer 1

0

I managed to produce something that looks a lot better, based on all the comments from above! It now looks like the following, in which everything is aligned as expected.

underlined text

This was produced with the following snippet

\newcommand{\customHeading}[1]{
    \noindent\smash{\LARGE #1}
    \strut
    \hrule height 1pt
}

This could probably be improved further, if you replace \hrule with \rule, but the above worked for me so I kept it as is.

You must log in to answer this question.

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