TransWikia.com

Tabularx and Longtable Alignment

TeX - LaTeX Asked on May 2, 2021

I’m trying to write my CV using tabularx, but I’m having some problems with getting some things to align. I’m using tabularx for sections on single pages, but longtable for sections spanning multiple pages. But the resulting tables do not align. Here’s a section of a (fake) CV illustrating the issue:

enter image description here

As you can just about see, the faint grey line has again been shifted rightwards in the longtable compared to the regular tables. How can I rectify this without changing all the tables to longtables? Thanks!

Here’s the code:

documentclass[10pt]{article}
usepackage[margin=20mm]{geometry}
title{vspace{-15mm}huge JOE BLOGGSvspace{-5mm}}
author{[email protected]}
date{}

usepackage{baskervillef} %font
usepackage[T1]{fontenc} %font
usepackage{nopageno} %eliminates page numbers
usepackage[explicit]{titlesec} %adjust titles
usepackage{longtable} %multi-page tables

usepackage{array, xcolor}
definecolor{lightgray}{gray}{0.8}
newcolumntype{L}{>{raggedleft}p{0.14textwidth}}
newcolumntype{R}{p{0.8textwidth}}
newcommandVRule{color{lightgray}vrule width 0.5pt}

setlength{parindent}{0pt}

titleformat{section}{normalfont}{thesection}{1em}{MakeUppercase{#1}}[vspace{1mm} titlerule]

begin{document}

maketitle

noindent Areas of Particular Interest: dogs, aardvarks, amazing birds of paradise.

vspace{1mm}

noindent Areas of Interest: cats, honey badgers, goldfish.

section*{Education}
begin{tabular}{L!{VRule}R}
    2018—2020 & MPhil in Zoology, University A.
    & hspace{5mm} MPhil Thesis: textit{999 Reasons Why Dogs Are Better than Cats}
    & hspace{5mm} Supervisors: Scooby & Snoopy
    & hspace{5mm} Examiners: Fido (Internal) & Laika (External) vspace{1mm}
    2014—2017 & BA in Zoology (First), University B.
end{tabular}

section*{Works in Progress}
begin{tabular}{L!{VRule}R}
    2020 & textit{Aardvarks and Their Discontents.} Revise & resubmit in the textit{Journal of Zoology}. vspace{1mm}
    2020 & textit{Should We Care for Wild Animals?} Revise & resubmit in textit{Zoological Studies}.
end{tabular}

section*{Presentations}

begin{tabular}{L!{VRule}R}
    February 2021 & textit{Should Animals Be Sent into Space?} Paper to be presented at the 24textsuperscript{th} Oxford Zoology Graduate Conference, University of Oxford, UK.vspace{1mm}
    July 2020 & textit{Why Do Cats Hate Water?} Paper presented at the 13textsuperscript{th} Annual Cambridge Graduate Conference on Zoology, University of Cambridge, UK.vspace{1mm}
end{tabular}

vspace{baselineskip}

begin{tabular}{L!{VRule}R}
    February 2020 & textit{Are Cats Really Smarter than Dogs? A Summary of Recent Research}. Paper presented at the Friday Seminar, University A, UK.vspace{1mm}
    December 2019 & textit{How Many Times Did Laika Orbit the Earth? Ethical Issues Surrounding Space Exploration} Paper presented at the Zoology Group, University A, UK.vspace{1mm}
end{tabular}

section*{Awards}

begin{tabular}{L!{VRule}R}
    2020 & Generic academic award for being amazing, contributing to the department, and many other things. University A, UK.vspace{1mm}
    2020 & Another generic academic award for being amazing, contributing to the department, and many other things. University A, UK.vspace{1mm}
    2020 & Another generic award for being amazing, contributing to the department, and many other things. University A, UK.vspace{1mm}
    2020 & Another generic award for being amazing, contributing to the department, and many other things. University A, UK.vspace{1mm}
    2020 & Another generic award for being amazing, contributing to the department, and many other things. University A, UK.vspace{1mm}
end{tabular}

section*{Teaching Experience}

begin{longtable}{L!{VRule}R}
    2020 & Taught Undergraduates Zoology. University A, UK.
    2020 & Taught Undergraduates Zoology. University A, UK.
    2020 & Taught Undergraduates Zoology. University A, UK.
    2020 & Taught Undergraduates Zoology. University A, UK.
    2020 & Taught Undergraduates Zoology. University A, UK.
end{longtable}

section*{Academic Service}

begin{tabular}{L!{VRule}R}
    2020 & Head of the Zoology Society. University A, UK.vspace{1mm}
    2020 & Convenor of the Zoology Reading Group. University A, UK.vspace{1mm}
    2020 & Referee, Zoology Graduate Conference. University A, UK.vspace{1mm}
end{tabular}

end{document}

One Answer

Is that what you want ?

If you want to change title , open article.cls, copy paste and change maketitle as you want :

makeatletter
    def@maketitle{%
  newpage
  null
  vskip 2em%
  begin{center}%
  let footnote thanks
    {huge @title par}% <=LARGE by default
    vskip 1.5em%
    {large
      lineskip .5em%
      begin{tabular}[t]{c}%
        @author
      end{tabular}par}%
    vskip 1em%
    {large @date}%
  end{center}%
  par
  vskip 1.5em}
makeatother

Edit :

documentclass[10pt]{article}
usepackage{etoolbox}
AtBeginEnvironment{tabularx}{medskip}%before
AtEndEnvironment{tabularx}{medskip}%after
usepackage[margin=20mm]{geometry}
title{ JOE BLOGGS}
author{[email protected]}
date{}

usepackage{baskervillef} %font
usepackage[T1]{fontenc} %font
usepackage{nopageno} %eliminates page numbers
usepackage[nobottomtitles,explicit]{titlesec} %adjust titles
usepackage{array,tabularx,longtable} %multi-page tables
usepackage[table]{xcolor}
definecolor{lightgray}{gray}{0.8}
newcolumntype{L}{>{raggedleft}p{0.14textwidth}}
newcolumntype{R}{p{0.8textwidth}}
newcommandVRule{color{lightgray}vrule width 0.5pt}%no need | do the same job perfectly

%titleformat{section}{normalfont}{textbf{}}{0em}{textbf{#1}}

titleformat{section}{normalfont}{thesection}{1em}{MakeUppercase{#1}}[ titlerule]

setlength{parindent}{0pt}
setlength{extrarowheight}{5pt}
arrayrulecolor{gray}
usepackage{lipsum}


    
    
begin{document}

maketitle

 Areas of Particular Interest: dogs, aardvarks, amazing birds of paradise.



 Areas of Interest: cats, honey badgers, goldfish.

section*{Education}
begin{tabularx}{textwidth}{L|@{quad}R}
    2018--2020 & MPhil in Zoology, University A.
%   & Attained distinctions in every module in first year.
    &  MPhil Thesis: textit{999 Reasons Why Dogs Are Better than Cats}
    & Supervisors: Scooby & Snoopy
    & Examiners: Fido (Internal) & Laika (External) 
    2014--2017 & BA in Zoology (First), University B.
    %& hspace{5mm} Upper Second Class.
    %2011--2013 & textbf{A Levels, King Edward VI School (Southampton)}
    %& Mathematics (A*), Chemistry (A*), Biology (A*), & Economics (A*).
end{tabularx}

section*{Works in Progress}
begin{tabularx}{textwidth}{L|@{quad}R}
    2020 & textit{Aardvarks and Their Discontents.} Revise & resubmit in the textit{Journal of Zoology}. 
    2020 & textit{Should We Care for Wild Animals?} Revise & resubmit in textit{Zoological Studies}.
end{tabularx}

section*{Presentations}

begin{tabularx}{textwidth}{L|@{quad}R}
    February 2021 & textit{Should Animals Be Sent into Space?} Paper to be presented at the 24textsuperscript{th} Oxford Zoology Graduate Conference, University of Oxford, UK.
    July 2020 & textit{Why Do Cats Hate Water?} Paper presented at the 13textsuperscript{th} Annual Cambridge Graduate Conference on Zoology, University of Cambridge, UK.
end{tabularx}

%vspace{baselineskip} %no need etooolbox do this for you

begin{tabularx}{textwidth}{L|@{quad}R}
    February 2020 & textit{Are Cats Really Smarter than Dogs? A Summary of Recent Research}. Paper presented at the Friday Seminar, University A, UK.
    December 2019 & textit{How Many Times Did Laika Orbit the Earth? Ethical Issues Surrounding Space Exploration} Paper presented at the Zoology Group, University A, UK.
end{tabularx}

section*{Awards}

begin{tabularx}{textwidth}{L|@{quad}R}
    2020 & Generic academic award for being amazing, contributing to the department, and many other things. University A, UK.
    2020 & Another generic academic award for being amazing, contributing to the department, and many other things. University A, UK.
    2020 & Another generic award for being amazing, contributing to the department, and many other things. University A, UK.
    2020 & Another generic award for being amazing, contributing to the department, and many other things. University A, UK.
    2020 & Another generic award for being amazing, contributing to the department, and many other things. University A, UK.
end{tabularx} 

section*{Teaching Experience}

begin{longtable}{L|@{quad}R}
   2020 & lipsum[1]
    2020 & lipsum[1]
    2020 & Taught Undergraduates Zoology. University A, UK.
    2020 & Taught Undergraduates Zoology. University A, UK.
    2020 & Taught Undergraduates Zoology. University A, UK.
end{longtable}


end{document}

enter image description here

Correct answer by Aviroum on May 2, 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