TransWikia.com

Adding vertical space after custom environment, excluding last in the surrounding environment

TeX - LaTeX Asked on May 28, 2021

I am fairly new to LaTeX, so please excuse my ignorance.

Here is a portion of my source. You will notice that I use vspace between _history environments. I know that I can add vspace to last {} of newenvironment, but this means the last _history will include the spacing. Is there a way to add vspace to _history, for all but the last _history within the surrounding environment (_section in this case)?

To compare this to CSS, we would do something like:

_section:not(:last-child) {
  ...
}
documentclass[letterpaper]{article}

usepackage[left=0.4in,top=0.4in,right=0.4in,bottom=0.4in]{geometry}
usepackage{enumitem}
usepackage{fontspec}
usepackage{ulem}
usepackage{xstring}
usepackage{ifthen}

renewcommand{ULdepth}{1.4pt}

setmainfont{Palatino Linotype}

newenvironment{_section}[1] {
    noindent
    textbf{textsc{#1}}
    smallskip
    hrule
    begin{list}{} { setlength{leftmargin}{0em} }
    item[]
}{  end{list}}

newenvironment{_history}[5] {
    StrLen{#2}[argTwoLen]
    StrLen{#4}[argFourLen]
    textbf{#1}ifthenelse{argTwoLen > 0}{, #2}{}hfill#3
    ifthenelse{argFourLen > 0}{textit{#4}}{}
    ifthenelse{equal{#5}{TRUE}}{vspace{4pt}}{}
}{}

begin{document}

begin{_section}{Technical Experience}
    begin{_history}{Perthera, Inc.}{Holliston MA}{05/2020 -- 08/2020}{Software Developer Intern}{FALSE}
        begin{itemize}[noitemsep,nolistsep]
            item Software development with uline{Java}---backend uline{RESTful APIs} and frontend UI.
            item Individually rewrote an entire application’s frontend with uline{Vaadin} 8 and some backend.
            item Individually updated projects with Ant/Ivy build systems to uline{Maven}.
            item Programmed interoperability between databases of different forms. I.e., importing data from one model to another, with a mix of uline{Java} and uline{SQL}. Used uline{JSON} for input parameters and output.
            begin{itemize}[noitemsep,nolistsep]
                item For example, I wrote a uline{RESTful API} to match data between a uline{SQL} database and HubSpot with a confidence algorithm, import some into HubSpot, or update the database.
            end{itemize}
            item Used uline{SQL} and MySQL with triggers and views.
        end{itemize}
    end{_history}
    vspace{2pt}
    begin{_history}{Massachusetts Bay Community College}{Wellesley MA}{01/2020 -- 05/2020}{Peer Tutor & Embedded Tutor}{FALSE}
        begin{itemize}[noitemsep,nolistsep]
            item Tutored students enrolled in Programming I and Basic Math through Calculus I.
            item Acted as a resource and guide to students struggling academically.
            item In-class tutor for Programming I labs.
        end{itemize}
    end{_history}
    vspace{2pt}
    begin{_history}{ALARM Robotics}{Franklin MA}{12/2019 -- Present}{Software Development Mentor}{TRUE}
        ALARM Robotics is a registered team in the FIRST Robotics Competition. Teams of high school students and adult mentors have six weeks to build a competitive robot.
        begin{itemize}[noitemsep,nolistsep]
            item Mentored high school students interested in programming.
            item Introduced programming concepts to mentees, such as uline{Object-Oriented Programming}, uline{Data Structures}, API usage, and basic embedded software design, with uline{Java}.
        end{itemize}
    end{_history}
end{_section}

end{document}

One Answer

I would make the skip length as an optional argument to _history with a default of (based on your code) 2pt. On the last invocation, pass [0pt] as the optional argument.

documentclass[letterpaper]{article}

usepackage[left=0.4in,top=0.4in,right=0.4in,bottom=0.4in]{geometry}
usepackage{enumitem}
usepackage{fontspec}
usepackage{ulem}
usepackage{xstring}
usepackage{ifthen}

renewcommand{ULdepth}{1.4pt}

setmainfont{Palatino Linotype}

newenvironment{_section}[1] {
    noindent
    textbf{textsc{#1}}
    smallskip
    hrule
    begin{list}{} { setlength{leftmargin}{0em} }
    item[]
}{  end{list}}

newlengthinterhistory

newenvironment{_history}[6][2pt] {%
    setlengthinterhistory{#1}%
    StrLen{#3}[argTwoLen]
    StrLen{#5}[argFourLen]
    textbf{#2}ifthenelse{argTwoLen > 0}{, #3}{}hfill#4
    ifthenelse{argFourLen > 0}{textit{#5}}{}
    ifthenelse{equal{#6}{TRUE}}{vspace{4pt}}{}
}{vspace{interhistory}}

begin{document}

begin{_section}{Technical Experience}
    begin{_history}{Perthera, Inc.}{Holliston MA}{05/2020 -- 08/2020}{Software Developer Intern}{FALSE}
        begin{itemize}[noitemsep,nolistsep]
            item Software development with uline{Java}---backend uline{RESTful APIs} and frontend UI.
            item Individually rewrote an entire application’s frontend with uline{Vaadin} 8 and some backend.
            item Individually updated projects with Ant/Ivy build systems to uline{Maven}.
            item Programmed interoperability between databases of different forms. I.e., importing data from one model to another, with a mix of uline{Java} and uline{SQL}. Used uline{JSON} for input parameters and output.
            begin{itemize}[noitemsep,nolistsep]
                item For example, I wrote a uline{RESTful API} to match data between a uline{SQL} database and HubSpot with a confidence algorithm, import some into HubSpot, or update the database.
            end{itemize}
            item Used uline{SQL} and MySQL with triggers and views.
        end{itemize}
    end{_history}
    begin{_history}{Massachusetts Bay Community College}{Wellesley MA}{01/2020 -- 05/2020}{Peer Tutor & Embedded Tutor}{FALSE}
        begin{itemize}[noitemsep,nolistsep]
            item Tutored students enrolled in Programming I and Basic Math through Calculus I.
            item Acted as a resource and guide to students struggling academically.
            item In-class tutor for Programming I labs.
        end{itemize}
    end{_history}
    begin{_history}[0pt]{ALARM Robotics}{Franklin MA}{12/2019 -- Present}{Software Development Mentor}{TRUE}
        ALARM Robotics is a registered team in the FIRST Robotics Competition. Teams of high school students and adult mentors have six weeks to build a competitive robot.
        begin{itemize}[noitemsep,nolistsep]
            item Mentored high school students interested in programming.
            item Introduced programming concepts to mentees, such as uline{Object-Oriented Programming}, uline{Data Structures}, API usage, and basic embedded software design, with uline{Java}.
        end{itemize}
    end{_history}
end{_section}
Blah-blah

end{document}

enter image description here

Correct answer by Steven B. Segletes on May 28, 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