1

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}
%%%%%
\author[a]{Megadeth}
%%%%%
\affiliation[a]{Rust In Peace...Polaris}
%%%%%
\emailAdd{thrash@metalupyourass.com}
%%%%%
\abstract{ 
A true masterpiece
}
%%%%%
\date{\today}
%%%%%
\begin{document}
No one knew what would happen there
No one spoke no one even dared
Don't ask what you can do for your country
Ask what your country can do for you
\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}%
\newcommand{\emailAdd}[1]{%
\emailaddtrue%
\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.

2
  • 1
    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

1 Answer 1

1
+100

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

  \usepackage{chet,myheader}

enter image description here


The TeX source of the sample document above:

\documentclass[12pt]{article}
\usepackage{chet,myheader}
\title{Take no prisoners}
\author[a]{First Author}
\author[b]{Second Author}
\affiliation[a]{First Affiliation}
\affiliation[b]{Second Affiliation}
\emailAdd{some@where.edu}
\emailAdd{some@where.else.edu}
\abstract{A true masterpiece}
\date{\today}
\begin{document}
\maketitle
No one knew what would happen there
No one spoke no one even dared
Don't ask what you can do for your country
Ask what your country can do for you
\end{document}

myheader.sty

\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
  \ifaffil\ifemailadd\\[2ex]\fi\fi
  \ifemailadd
    \textit{E-mail:} \the\email@toks
  \fi
}

\newif\ifemailadd\emailaddfalse
\newtoks\email@toks\newcounter{email@counter}%
\setcounter{email@counter}{0}%
\newcommand{\emailAdd}[1]{%
\emailaddtrue%
\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}}
3
  • Thanks for your time and for writing an answer. I have been playing around for days with this suggestion. The thing is that is uses the page format of jheppub. The only thing I would like to keep from jheppub, is the way of coding the authors and affiliations, and that's it. The page style etc, I would like them to be from the chet.sty.
    – user201099
    Jan 6 at 16:28
  • 1
    @DiSp0sablE_H3r0 I have adjusted my answer. Check whether it is now what your want.
    – gernot
    Jan 6 at 22:14
  • that's just brilliant. thanks for your time!
    – user201099
    Jan 6 at 22:22

Your Answer

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