1

I would like to insert a logo in the top center of the first page, before the title and the authors name. If I use the command \begin{figure} it turns out another new page before the title with the image. I have also tried not to use \begin{figure}. The main text code is below:

 %\documentclass[5p,sort&compress]{elsarticle}
\documentclass[final,5p,times,twocolumn,authoryear]{elsarticle}

\makeatletter \def\ps@pprintTitle{% \let@oddhead@empty \let@evenhead@empty \def@oddfoot{\footnotesize\itshape \hfill\today}% \let@evenfoot@oddfoot} \makeatother

\usepackage{dcolumn} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{cleveref} \usepackage{textcomp} \usepackage{mathtools} \usepackage{lmodern} \usepackage[english]{babel} \usepackage[fixlanguage]{babelbib} \renewenvironment{abstract}{\global\setbox\absbox=\vbox\bgroup \hsize=\textwidth\def\baselinestretch{1}% \noindent\unskip\textbf{Abstract} \par\medskip\noindent\unskip\ignorespaces} {\egroup}

\usepackage{amsmath} \usepackage{amssymb} \usepackage{caption} \usepackage{booktabs} \usepackage[utf8]{inputenc} \usepackage[table]{xcolor} \usepackage{caption} \usepackage{listings} \usepackage{gensymb} \usepackage{xcolor} \usepackage[title]{appendix} \usepackage{appendix} \usepackage[toc,page]{appendix} \usepackage{bm} \usepackage{siunitx} \sisetup{ exponent-product = \cdot, output-decimal-marker = {,}, separate-uncertainty = true, per-mode = symbol, group-digits = false, } \usepackage{graphicx} \renewcommand{\topfraction}{.85} \renewcommand{\bottomfraction}{.7} \renewcommand{\textfraction}{.15} \renewcommand{\floatpagefraction}{.66} \setcounter{topnumber}{3} \setcounter{bottomnumber}{2} \setcounter{totalnumber}{10} \usepackage{flafter} \usepackage{booktabs} \usepackage{multirow} \usepackage[font=small,labelfont=bf]{caption} \usepackage[colorlinks=true,allcolors=blue]{hyperref} \usepackage{float} \restylefloat{table}

\usepackage{floatrow} \usepackage{graphicx} \usepackage{subfig} \usepackage{caption} \usepackage{subcaption} \usepackage[utf8]{inputenc} \usepackage{fancyhdr} \usepackage{lastpage} \usepackage{chemformula} %chemical formulas can be written more easily using \ch \usepackage[version=4]{mhchem} \usepackage{amsmath} % lar deg dele opp equations \usepackage{mathtools} % dele opp eq. \usepackage{titlesec} \pagestyle{fancy} \fancyhf{} \rfoot{Page \thepage \hspace{1pt} of \pageref{LastPage}}

%For at section, subsection og subsubsection skal bli deecent \titleformat{\section} {\normalfont\fontfamily{phv}\fontsize{12}{15}\bfseries}{\thesection}{1em}{} \titleformat{\subsection} {\normalfont\fontfamily{phv}\fontsize{10}{13}\bfseries}{\thesubsection}{1em}{} \titleformat{\subsubsection} {\normalfont\fontfamily{phv}\fontsize{10}{13}\selectfont}{\thesubsubsection}{1em}{}

\urlstyle{same}

\begin{document} \begin{frontmatter} \centering\includegraphics[width = .8\linewidth]{img/logo-polimi_600x250.png}

\title{Laboratory experiment 1: Magnetic Nanoparticles}

\author{} \address{}

\begin{abstract} text \end{abstract}

\end{frontmatter}

\input{text/01_Introduction} \input{text/02_Materials&methods} \input{text/03_Results&discussion} \input{text/04_Conclusion}

\makeatother \bibliographystyle{babunsrt} \bibliography{references}

\end{document}

  • Welcome to TeX.SE. Please, check https://tex.stackexchange.com/help/how-to-ask and What makes a good MWE?. Remove unnecessary packages and keep only to ones that interferes with your issue. By the way, avoid inserting \inputs, since other people don't have the file, specially when they are not related to the question. – FHZ Mar 15 '22 at 17:58
  • Please provide a document that we can compile without errors. Did you run your code? There are errors in your preamble, you use files we don't have, and other problems. I have tried to make it compilable but gave up as it was taking too much effort. – Peter Wilson Mar 15 '22 at 18:40
  • 1
    You should really fix the package conflicts, and the re-loading of appendix three times before you do everything else. If you're making this many changes, are you sure elsarticle is the right document class? – frabjous Mar 15 '22 at 19:03

2 Answers2

1

I relented and produced a very cut down version of your MWE and placed a graphic above your title.

% logoprob.tex  SE 637240

%\documentclass[5p,sort&compress]{elsarticle} \documentclass[final,5p,times,twocolumn,authoryear]{elsarticle}

\usepackage{graphicx} \usepackage{mwe} %%%% PW added for the image

\begin{document} \begin{frontmatter} %\centering\includegraphics[width = .8\linewidth]{img/logo-polimi_600x250.png}

\title{{\begin{center}\includegraphics{example-image-a}\end{center}} \vspace{1cm}Laboratory experiment 1: Magnetic Nanoparticles}

\author{A. N. Author} \address{Somewhere}

\begin{abstract} text \end{abstract}

\end{frontmatter}

\end{document}

enter image description here

Peter Wilson
  • 28,066
  • Here too I suggest using \texorpdfstring inside \title{...} to prevent the extra commands from getting in to the PDF metadata. – frabjous Mar 15 '22 at 19:27
0

I removed all packages and other commands except for the section \makeatletter\def\ps@pprintTitle (it removes the Preprint submitted to Elsevier).

The lazy solution I applied was to insert \centering\includegraphics[width=0.3\linewidth]{example-image-1x1}\\ inside the definition of title. Not the most elegant solution, but a simple one. I replaced your figure for one from the standard installation example-image.

I also added the package lipsum to better visualize the contents from abstract and sections.

Suggestions for creating your own customized title page:

A MWE follows:

\documentclass[final,5p,times,twocolumn,authoryear]{elsarticle}

\usepackage{lipsum}

\title{\centering \includegraphics[width=0.3\linewidth]{example-image-1x1}\ Laboratory experiment 1:\ Magnetic Nanoparticles}

\author{Author} \address{Address}

\makeatletter \def\ps@pprintTitle{% \let@oddhead@empty \let@evenhead@empty \def@oddfoot{\footnotesize\itshape \hfill\today}% \let@evenfoot@oddfoot} \makeatother

\begin{document} \begin{frontmatter} \begin{abstract} \lipsum[65-68] \end{abstract} \end{frontmatter}

\section{First section}

\lipsum[66-67]

\end{document}

enter image description here

FHZ
  • 3,939
  • 1
    I suggest using \texorpdfstring inside \title{...} to prevent the extra commands from getting in to the PDF metadata. – frabjous Mar 15 '22 at 19:01