TransWikia.com

Stray space before tabular environment

TeX - LaTeX Asked by Pond892 on June 30, 2021

I have a cover letter with the following:

documentclass[12pt]{letter}
usepackage[left=1.0in,top=1.0in,right=1.0in,bottom=1.0in]{geometry}
title{title}
    author{author}
    date{date}
    usepackage{geometry}
    geometry{letterpaper, portrait, margin=1in}
    pagenumbering{gobble} 
    begin{document}
    begin{flushright}hfillbegin{tabular}{l@{}}
        Name 
        Address 
        City, State 12345 \
        00 Month Year
    end{tabular}
    end{flushright}

bigskip 

begin{flushleft}
    Name 
    School 
    Address 
    City, State 12345 
 end{flushleft}

The text box with begin{tabular} (first instance of name, address, etc.) appears to be flush with the 1 inch margin on the right side. However, for some reason, there is a tiny space between the text box and the 1 inch margin on the top. Using a tape measure the space is 1/16th of an inch. How do I remove this space and make the text box flush with the top 1 inch margin? Thanks

2 Answers

I found there is actually this option: https://texblog.org/2007/08/15/writing-a-letter-in-latex/ which lets me format a cover letter automatically. My question above came about as a result of trying to format a cover letter manually rather than using the linked method.

Correct answer by Pond892 on June 30, 2021

The tabular lines have a minimum height, which is htstrutbox and is larger than the height of a capital letter.

You need to remove this difference. However, a vertical space at the top of a page would be removed unless you use vspace*; this trigger the insertion of topskip glue and also lineskip glue because the tabular needs to be typeset with b alignment.

documentclass{article}
usepackage{geometry}
geometry{letterpaper, portrait, margin=1in,showframe}

begin{document}

begin{flushright}
%% remove the topskip, the lineskip and the difference
%% between a capital letter and the height of a strut
vspace*{dimexprfontcharhtfont`N-htstrutbox-topskip-lineskip}
%% Now typeset the tabular with bottom alignment
begin{tabular}[b]{l@{}}
Name 
Address 
City, State 12345 \
00 Month Year
end{tabular}
end{flushright}

end{document}

enter image description here

The rules are the effect of showframe, in order to clearly show the placement. Remove the option for the production version.

I wouldn't bother with this tiny difference, which actually is 1/46th of an inch, at 10pt size and 1/37th at 12pt size, in any case less than 2pt.

Answered by egreg on June 30, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP