如何在新環境中編寫垂直間距的 if else 條件

如何在新環境中編寫垂直間距的 if else 條件

我定義了一個環境,​​如下圖。我想要進行修改,如果沒有提供參數,它不會添加白色垂直空間。

\documentclass[10]{article}
\usepackage[a4paper, margin=1in]{geometry}
\usepackage{tabu}

\usepackage{enumitem}
\setlist{leftmargin=5mm, noitemsep, topsep=-1\parskip}

\newenvironment{cvsection}[1]{
    \vspace{3pt}
    \hspace{3pt}{\scriptsize{\textbf{#1}}}
    \vspace{2pt}
    \hrule
}

\newenvironment{cvsubsection}[3]{
    \vspace{-8pt}
    \begin{center}
        \begin{tabu} to 1\textwidth { X[l,m] X[c,m] X[r,m] }
            \textbf{\small #1} & \textbf{\small #2} & \textbf{\small #3} \\
        \end{tabu}  
    \end{center}
}

\begin{document}
    \begin{cvsection}{LANGUAGES \& TECHNOLOGIES}
        \begin{cvsubsection}{}{}{}  
            \begin{itemize}
                \item C++; C; Java; Objective-C; C\#.NET; SQL; JavaScript; XSLT; XML (XSD) Schema 
                \item Visual Studio; Microsoft SQL Server; Eclipse; XCode; Interface Builder
            \end{itemize}
        \end{cvsubsection}
    \end{cvsection}
\end{document}

上面給出了以下內容。如果我不向我的cvsubsection.如果我確實提供了參數,它應該按照上面定義的方式工作。

在此輸入影像描述

所需的輸出以及相關程式碼(注意程式碼只是為了顯示我想要的輸出。我仍然想將空參數傳遞給我的cvsubsection

\begin{cvsection}{LANGUAGES \& TECHNOLOGIES}
%   \begin{cvsubsection}{}{}{}
    \vspace{4pt}
        \begin{itemize}
            \item C++; C; Java; Objective-C; C\#.NET; SQL; JavaScript; XSLT; XML (XSD) Schema 
            \item Visual Studio; Microsoft SQL Server; Eclipse; XCode; Interface Builder
        \end{itemize}
%   \end{cvsubsection}
\end{cvsection}

在此輸入影像描述

答案1

一個只檢查 cvsubsection 的第一個參數的想法(因為我覺得如果這是空的......其他的也將是空的 - 請隨意要求我將檢查擴展到其他的 - )

\documentclass{article}
\usepackage{tabu}
\usepackage{enumitem}
\setlist{leftmargin=5mm, noitemsep, topsep=-1\parskip}

\newenvironment{cvsection}[1]{
    \vspace{3pt}
    \hspace{3pt}{\scriptsize{\textbf{#1}}}
    \vspace{2pt}
    \hrule
}

\newenvironment{cvsubsection}[3]{
    \edef\FirstArg{#1}
    \ifx\FirstArg\empty\vspace{-25pt}\fi
    \begin{center}
        \begin{tabu} to 1\textwidth { X[l,m] X[c,m] X[r,m] }
            \textbf{\small #1} & \textbf{\small #2} & \textbf{\small #3} \\
        \end{tabu}  
    \end{center}
}

\begin{document}
    \begin{cvsection}{LANGUAGES \& TECHNOLOGIES}
        \begin{cvsubsection}{}{}{}  
            \begin{itemize}
                \item C++; C; Java; Objective-C; C\#.NET; SQL; JavaScript; XSLT; XML (XSD) Schema 
                \item Visual Studio; Microsoft SQL Server; Eclipse; XCode; Interface Builder
            \end{itemize}
        \end{cvsubsection}

        \begin{cvsubsection}{Arg2}{Arg3}{Arg4}  
            \begin{itemize}
                \item C++; C; Java; Objective-C; C\#.NET; SQL; JavaScript; XSLT; XML (XSD) Schema 
                \item Visual Studio; Microsoft SQL Server; Eclipse; XCode; Interface Builder
            \end{itemize}
        \end{cvsubsection}
    \end{cvsection}
\end{document}

在此輸入影像描述

相關內容