1

My cls file has the following

\newcommand{\jobentry}[5]{
    {\raggedleft\textsc{#1\expandafter\ifstrequal\expandafter{#2}{}{}{\hspace{6pt}\footnotesize{(#2)}}}\par} % Duration and conditional full time/part time text
    \expandafter\ifstrequal\expandafter{#3}{}{}{{\raggedright\large #3}\\} % Employer
    \expandafter\ifstrequal\expandafter{#4}{}{}{{\raggedright\large\textit{\textbf{#4}}}\\[4pt]} % Job title
    \expandafter\ifstrequal\expandafter{#5}{}{}{#5} % Description
    \medskip % Vertical whitespace
}

And, in my tex file, I have the following content

\jobentry
    {Jun 2021 -- Apr 2023} % Duration
    {FT} % FT/PT (full time or part time)
    {ABC Corp} % Employer
    {Software Engineer} % Job title
    {In this summer job I was tasked with helping eradicate pests from industrial areas. Work involved setting traps, spraying and eradication. } % Description

This produces the following output on the pdf.

enter image description here

However, I want to ABC Corp on left and Jun 2021 -- Apr 2023 (FT) on right like it is now, but I want them both to be in the same line. How can I achieve this?

3 Answers 3

2

(I'm going to preface this by saying I don't see a situation where #3, #4, or #5 should be blank, so I'm only going to test for #2 being blank.)

It wouldn't be too hard to adapt BanDoP's solution to the cls file and have something like {\large#3}\hfill\textsc{#1\ifstrequal{#2}{}{}{\hspace{6pt}\footnotesize(#2)}}\\. (Note also that \footnotesize is a switch like \large, so you don't need {}. You also don't need the \expandafters. But you do now need a \noindent.) This is \jobentryOne.

You could emphasize that #2 is optional by using [] instead of {}, so that you could leave it out if it wasn't necessary. This is \jobentryTwo.

\documentclass{article}

\usepackage{etoolbox} % needed for \ifstrequal
% \usepackage{xparse} % needed for \NewDocumentCommand if your TeX version isn't new enough

\newcommand{\jobentryZero}[5]{
    {\raggedleft\textsc{#1\expandafter\ifstrequal\expandafter{#2}{}{}{\hspace{6pt}\footnotesize{(#2)}}}\par} % Duration and conditional full time/part time text
    \expandafter\ifstrequal\expandafter{#3}{}{}{{\raggedright\large #3}\\} % Employer
    \expandafter\ifstrequal\expandafter{#4}{}{}{{\raggedright\large\textit{\textbf{#4}}}\\[4pt]} % Job title
    \expandafter\ifstrequal\expandafter{#5}{}{}{#5} % Description
    \medskip % Vertical whitespace
}

\newcommand{\jobentryOne}[5]{%
    \noindent
    {\large#3}\hfill\textsc{#1\ifstrequal{#2}{}{}{\hspace{6pt}\footnotesize(#2)}}\\
    {\raggedright\large\textit{\textbf{#4}}}\smallskip\\ % Job title
    #5 % Description
    \medskip % Vertical whitespace
}

\NewDocumentCommand{\jobentryTwo}{mommm}{%
    \noindent
    {\large#3}\hfill\textsc{#1\IfValueT{#2}{\hspace{6pt}\footnotesize(#2)}}\\
    {\raggedright\large\textit{\textbf{#4}}}\smallskip\\ % Job title
    #5 % Description
    \medskip % Vertical whitespace
}

\begin{document}

\jobentryZero
    {Jun 2021 -- Apr 2023} % Duration
    {FT} % FT/PT (full time or part time)
    {ABC Corp} % Employer
    {Software Engineer} % Job title
    {In this summer job I was tasked with helping eradicate pests from industrial areas. Work involved setting traps, spraying and eradication. } % Description

\jobentryOne
    {Jun 2021 -- Apr 2023} % Duration
    {FT} % FT/PT (full time or part time)
    {ABC Corp} % Employer
    {Software Engineer} % Job title
    {In this summer job I was tasked with helping eradicate pests from industrial areas. Work involved setting traps, spraying and eradication. } % Description

\jobentryTwo
    {Jun 2021 -- Apr 2023} % Duration
    [FT] % FT/PT (full time or part time)
    {ABC Corp} % Employer
    {Software Engineer} % Job title
    {In this summer job I was tasked with helping eradicate pests from industrial areas. Work involved setting traps, spraying and eradication. } % Description

\jobentryTwo
    {Jun 2021 -- Apr 2023} % Duration
    {ABC Corp} % Employer
    {Software Engineer} % Job title
    {In this summer job I was tasked with helping eradicate pests from industrial areas. Work involved setting traps, spraying and eradication. } % Description

\end{document}

code output

1

Edited
Like this?

enter image description here

For above result the definition for \jobentry can be much simpler. It not need to employ etoolbox and its \ifstrequal macro and any expandafter.

Code for \jobentry assumed, that all field in the command are always present (this is not clear from question):

\documentclass{article}
\usepackage{lipsum}
\newcommand{\jobentry}[5]%
{\par\medskip\setlength\parindent{0pt}
    {\raggedright\large #3}                         % Employer
        \hfill
    {\footnotesize\textsc{#1}\hspace{6pt} (#2)}\par % Duration and conditional full time/part time text
    {\large\textit{\textbf{#4}}}\\[4pt]             % Job title
    {#5}                                            % Description
    \medskip                                        % Vertical whitespace
}


\begin{document}
\lipsum[66]
\jobentry%
    {Jun 2021 -- Apr 2023}  % Duration
    {FT}                    % FT/PT (full time or part time)
    {ABC Corp}              % Employer
    {Software Engineer}     % Job title
    {In this summer job I was tasked with helping eradicate pests from industrial areas. Work involved setting traps, spraying and eradication. } % Description
    
\jobentry
    {Jun 2021 -- Apr 2023}  % Duration
    {FT}                    % FT/PT (full time or part time)
    {ABC Corp}              % Employer
    {Software Engineer}     % Job title
    {In this summer job I was tasked with helping eradicate pests from industrial areas. Work involved setting traps, spraying and eradication. } % Description
\end{document}

enter image description here

0

You could simply use \hfill, e.g.,

Jun 2021 -- Apr 2023 (FT) \hfill ABC Corp\\
Software Engineer
1
  • I would want to edit the cls file and not edit on the tex itself Oct 9, 2023 at 6:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .