# Combining two different .sty files into one

I am pretty sure that I am making a very simple mistake, but I am stuck with this for hours.

So, the situation is the following: there is the chet.sty that I like using a lot for writing my pdfs. However, I would prefer to use the format of the jheppub.sty only for the authors, affiliations, and emails and nothing more. Hence, ideally, I would just like to copy and replace the relevant part of jheppub.sty to chet.sty, and create my document.

I isolated the part pertaining to affiliations, authors and emails from the jheppub.sty and copied them into the chet.sty I ran into some problems.

Does anyone have any ideas?

What I would ideally like to achieve is the following:

\documentclass[12pt]{article}
%%%%%
\usepackage{chet}
%%%%%
\title{Take no prisoners}
%%%%%
%%%%%
\affiliation[a]{Rust In Peace...Polaris}
%%%%%
%%%%%
\abstract{
A true masterpiece
}
%%%%%
\date{\today}
%%%%%
\begin{document}
No one knew what would happen there
No one spoke no one even dared
\end{document}


to run without any issues.

I am providing links to the relevant .sty files as they are too long to be provided explicitly here.

1. The chet.sty file
2. The jheppub.sty file

I tried the following: I took the following part from the second .sty

%authors and affiliations
\newtoks\auth@toks
\renewcommand{\author}[2][]{%
\if!#1!%
\auth@toks=\expandafter{\the\auth@toks#2\ }%
\else
\auth@toks=\expandafter{\the\auth@toks#2$^{#1}$\ }%
\fi
}

\newtoks\affil@toks\newif\ifaffil\affilfalse
\newcommand{\affiliation}[2][]{%
\affiltrue
\if!#1!%
\affil@toks=\expandafter{\the\affil@toks{\item[]#2}}%
\else
\affil@toks=\expandafter{\the\affil@toks{\item[$^{#1}$]#2}}%
\fi
}

%emails
%automatically put a comma between emails
\newtoks\email@toks\newcounter{email@counter}%
\setcounter{email@counter}{0}%
\ifnum\theemail@counter>0\email@toks=\expandafter{\the\email@toks, \@email{#1}}%
\else\email@toks=\expandafter{\the\email@toks\@email{#1}}%
\fi\stepcounter{email@counter}}
\newcommand{\@email}[1]{\href{mailto:#1}{\tt #1}}


and pasted it into chet.sty right below

%Titlepage
\renewcommand{\abstract}[1]{\def\@abstract {\begin{center}\textbf{Abstract} \\\end{center}#1}}
\newcommand{\affiliation}[1]{\def\@affiliation {#1}}
\newcommand{\preprint}[1]{\def\@preprint {#1}}
\abstract{}
\affiliation{}
\preprint{}


Edit: I tried to implement the suggestion at the comment from @DavidCarlisle but no success yet.

• you would probably need the \maketiitle definition to go with your author definitions from teh first package, but do not edit the chet.sty from the texlive distribution, that will be confusing, and your changes will be lost at any update, copy the new changed file to mychet.sty and use \usepackage{mychet} Dec 31, 2021 at 11:09
• @DavidCarlisle thanks for the tip. I will give it a go and see how it goes!!!
– user201099
Dec 31, 2021 at 18:45

Copy the code at the end of the post to a file called myheader.sty and load it after chet:

  \usepackage{chet,myheader}


The TeX source of the sample document above:

\documentclass[12pt]{article}
\title{Take no prisoners}
\author[a]{First Author}
\author[b]{Second Author}
\affiliation[a]{First Affiliation}
\affiliation[b]{Second Affiliation}
\abstract{A true masterpiece}
\date{\today}
\begin{document}
\maketitle
No one knew what would happen there
No one spoke no one even dared
\end{document}


\newtoks\auth@toks
\renewcommand{\author}[2][]{%
\if!#1!%
\auth@toks=\expandafter{\the\auth@toks#2\ }%
\else
\auth@toks=\expandafter{\the\auth@toks#2$^{#1}$\ }%
\fi
}
\renewcommand\@author{\the\auth@toks}

\newtoks\affil@toks\newif\ifaffil\affilfalse
\def\affiliation{}
\renewcommand\affiliation[2][]{%
\affiltrue
\if!#1!%
\affil@toks=\expandafter{\the\affil@toks&#2\\}%
\else
\affil@toks=\expandafter{\the\affil@toks$^{#1}$&#2\\}%
\fi
}

\def\@affiliation{}
\renewcommand\@affiliation{%
\ifaffil
{\small
\begin{tabular}{@{}r@{\,}l@{}}
\the\affil@toks
\end{tabular}}%
\fi
\textit{E-mail:} \the\email@toks
\fi
}

\newtoks\email@toks\newcounter{email@counter}%
\setcounter{email@counter}{0}%
`