I defined a command to insert figures easier and according to some college formatting. It is working just fine, but I am having a problem trying to add a conditional statement. The command is this:
%\figura{fig-location}{caption}{width(0-1)}{Source(if own, leavy empty)}{label}
\newcommand{\figura}[5]{
\begin{figure}[H]
\begin{minipage}{\textwidth}
\caption[#2]{\raggedright #2}
\label{fig:#5}
\begin{center}
\includegraphics[width=#3\textwidth]{#1}\\
\end{center}
\textbf{Fuente: }#4
\end{minipage}
\end{figure}
}
The output is as I want it to be, here is an example:
However, some figures are made by me, and I don't need to cite the source of such figures. Source is the word Fuente (Spanish). So I want to modify the command with a conditional so that when I leave the #4
argument empty, it does not print the word Fuente:
under the figure. Id est:
If
#4 =
, then do nothing.If
#4 = something
, then write under the figureFuente: #4
.
Is it possible to realise the above pseudocode? If so, how can I?
I found this in another post, but it only works with the exact word "something", I need it to work with anything different from an empty argument:
\documentclass{article}
\usepackage{xstring}
\newcommand{\example}[2]{%
\IfEqCase{#1}{%
{}{$\sqrt{#2}$}%
{something}{Fuente: XYZ}%
% you can add more cases here as desired
}
[\PackageError{tree}{Undefined option to tree: #1}{}]%
}%
\begin{document}
\example{}{None}
\example{something}{}
\end{document}
\edef\tempa{}\edef\tempb{#4}\ifx\tempa\tempb\relax\else Fuente: #4\fi
? But I would usexparse
and\NewDocumentCommand
so you can utilise\IfValueT{#4}{Fuente: #4}
etc.