在自定义环境后添加垂直空间,排除周围环境中的最后一个

在自定义环境后添加垂直空间,排除周围环境中的最后一个

我对 LaTeX 还很陌生,所以请原谅我的无知。

以下是我的源代码的一部分。您会注意到我使用了环境\vspace之间_history。我知道我可以添加到的\vspace最后一个,但这意味着最后一个将包含间距。有没有办法将 添加到,除了周围环境中的最后一个之外的所有(在本例中)?{}\newenvironment_history\vspace_history_history_section

为了将其与 CSS 进行比较,我们可以执行以下操作:

_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}

答案1

我将跳过长度作为可选参数,_history默认值为 (基于您的代码) 2pt。在最后一次调用时,将其[0pt]作为可选参数传递。

\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}}

\newlength\interhistory

\newenvironment{_history}[6][2pt] {%
    \setlength\interhistory{#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}

在此处输入图片描述

相关内容