Page Layoutmodify maketitle with authblk

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Ant0in8
Posts: 5
Joined: Wed Oct 03, 2012 6:29 pm

modify maketitle with authblk

Post by Ant0in8 »

Hi! I am trying to modify maketitle using the package authblk. But it doesn't work until now, and I cannot manage to find the reason(s). Thanks in advance for your help.

Code: Select all

\documentclass{article}
\makeatletter
\usepackage{hyperref} 
\usepackage{authblk}

\newcommand{\address}[1]{\newcommand{\@address}{#1}}
\newcommand{\institute}[1]{\newcommand{\@institute}{#1}}

\renewcommand{\maketitle}{
 {\LARGE\noindent\ignorespaces\@title\par}
 {\Large\noindent\ignorespaces\@author\par}
 {\normalsize\noindent\ignorespaces\@affil\par}
 {\normalsize\noindent\ignorespaces\@institute\par} 
 {\normalsize\noindent\ignorespaces\@address\par}
 {\normalsize\noindent\ignorespaces\@date\par}
}

\begin{document}
\title{Draft in progress}
\author[a]{authorA}
\author[b]{authorB}
\affil[a]{\href{mailto:authorA@email.com}{authorA@email.com}}
\affil[b]{\href{mailto:authorB@email.com}{authorB@email.com}}
\institute{University}
\address{earth}
\date{\today}
\maketitle
(blablabla)
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

modify maketitle with authblk

Post by Johannes_B »

\affil takes two arguments and the definition behind is much more complicated than for author or title of the standard article class. Package authblk takes all the author and affiliation information, packs it together and def's \@author.

Simply try the following:

Code: Select all

\documentclass{article}
\usepackage{authblk}

\makeatletter
\newcommand{\address}[1]{\newcommand{\@address}{#1}}
\newcommand{\institute}[1]{\newcommand{\@institute}{#1}}

\renewcommand{\maketitle}{
	{\LARGE\noindent\ignorespaces\@title\par}
	{\Large\noindent\ignorespaces\@author\par}
%	{\normalsize\noindent\ignorespaces\@affil\par}
	{\normalsize\noindent\ignorespaces\@institute\par}
	{\normalsize\noindent\ignorespaces\@address\par}
	{\normalsize\noindent\ignorespaces\@date\par}
}
\makeatother

\renewcommand{\Affilfont}{\normalsize}
\usepackage{hyperref}%usually loaded last
\begin{document}
\title{Draft in progress}
\author[a]{authorA}
\author[b]{authorB}
\affil[a]{\href{mailto:authorA@email.com}{authorA@email.com}}
\affil[b]{\href{mailto:authorB@email.com}{authorB@email.com}}
\institute{University}
\address{earth}
\date{\today}
\maketitle
(blablabla)
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Ant0in8
Posts: 5
Joined: Wed Oct 03, 2012 6:29 pm

Re: modify maketitle with authblk

Post by Ant0in8 »

thanks, it works! I have an other question, if I want that the affils appear after institute, how should I do? I tried the very naive thing to just write the two \affil after \institute, but it doesn't work. thank you in advance.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: modify maketitle with authblk

Post by Johannes_B »

As said before, the author and affil information are packed together in \@author. You would need patch the original authblk commands. But look at the file, it is a mess.

If the package is actively maintained, you could ask for some feature request. But since institute isn't a native command ...
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Ant0in8
Posts: 5
Joined: Wed Oct 03, 2012 6:29 pm

Re: modify maketitle with authblk

Post by Ant0in8 »

ok, thanks a lot for your help!
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

modify maketitle with authblk

Post by Johannes_B »

You can do something like the following, but to be quite honest, i don't know why you are using authblk. If you would be a bit more verbose about your goals, we could find another solution.

Code: Select all

\documentclass{article}
\makeatletter
\usepackage{authblk}

\makeatletter
\newcommand{\address}[1]{\newcommand{\@address}{#1}}
\newcommand{\institute}[1]{\newcommand{\@institute}{#1}}

\renewcommand{\maketitle}{
	{\LARGE\noindent\ignorespaces\@title\par}
	{\Large\noindent\ignorespaces\@author\par}
%	{\normalsize\noindent\ignorespaces\@affil\par}
	{\normalsize\noindent\ignorespaces\@institute\par}
	{\normalsize\noindent\ignorespaces\@address\par}
	{\normalsize\noindent\ignorespaces\@date\par}
}
\newcommand\institutefont{\normalsize}

\renewcommand{\Affilfont}{\normalsize}
\renewcommand\@author{\ifx\AB@affillist\AB@empty\AB@author\else
      \ifnum\value{affil}>\value{Maxaffil}\def\rlap##1{##1}%
      \AB@authlist\\{\institutefont\@institute}\\[\affilsep]\AB@affillist
    \else  \AB@authors\fi\fi}
\makeatother
\usepackage{hyperref}%usually loaded last
\begin{document}
\title{Draft in progress}
\author[a]{authorA}
\author[b]{authorB}
\affil[a]{\href{mailto:authorA@email.com}{authorA@email.com}}
\affil[b]{\href{mailto:authorB@email.com}{authorB@email.com}}
\institute{University}
\address{earth}
\date{\today}
\maketitle
(blablabla)
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply