# How to write if else condition for vertical spacing in newenvironment

I have defined an environment as follows. I would like to have a modification where, it does not add white vertical space if no arguments are provided.

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


The above gives the following. I would like to remove the white spacing marked in red, if I don't provide arguments to my cvsubsection. If I do provide arguments, it should work as already defined above.

Desired output with relevant code (NOTE code is just to show the output what I want. I still want to pass empty arguments to my 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}


An idea with check of only the first argument of cvsubsection (since I feel that if this is empty... the others will be empty too -feel free to ask me to extend the check to the others too-)

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


• Thank you. This works. Yes checking first argument is enough. I just have to modify the spacing. But the answer helps thanks. – scientific_explorer Mar 2 at 14:08
• Hi, if you don't mind, can you please suggest book(s) to learn latex? – scientific_explorer Mar 2 at 14:13
• I am afraid I am not the right person to answer but check this: tex.stackexchange.com/q/11/120578 ... My opinion is that you can start from online search for the first steps, then maybe "the not so short introduction to LaTeX2ε" (at least parts of it) and for me... after these you should have a look at "the TeXbook" of the creator of TeX typesetting system. But this is something I haven't done yet and I should do asap. – koleygr Mar 2 at 14:17