我定义了一个环境,如下所示。我想进行修改,如果未提供任何参数,则不会添加白色垂直空间。
\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}