1

I'm trying to create a custom header command that outputs something like this:

In MyCity, dd-mm-yyyy by Somebody with something

For that, I have custom commands to define each part

\newcommand{\myCity}[1]{\def\@myCity{#1}}
\newcommand{\myDate}[1]{\def\@myDate{#1}}

And yet another command to output it all

\newcommand{\makeThings}{

\ifdefined\@myCity

    \textbf{\@myCity}\textit{\@charDeathCity,\@charDeathDate})

\fi

\ifdefined\@myDate

    \textit{, \@myDate})

\fi

}

What I don't know, is how to have all the output from the \makeThings command in the same line. As it is, each if will be output in a different line. Can somebody, please, give me a help here?

2

Blank lines are the same as \par:

\makeatletter
\newcommand{\myCity}[1]{\def\@myCity{#1}}
\newcommand{\myDate}[1]{\def\@myDate{#1}}

\newcommand{\makeThings}{%
  \ifdefined\@myCity
    \textbf{\@myCity}\textit{\@charDeathCity,\@charDeathDate}) % space here
  \fi
  \ifdefined\@myDate
    \textit{, \@myDate})% no space here
  \fi
}
\makeatother

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.