titlesec
is able to do what you need:
\documentclass[12pt]{article}
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\normalsize\bfseries}{\thesection.}{1em}{}
\titleformat{\subsection}
{\normalfont\normalsize\itshape}{\thesubsection.}{1em}{}
\titleformat{\subsubsection}
{\normalfont\normalsize\itshape}{\thesubsubsection.}{1em}{}
\begin{document}
\section{Test}
\subsection{Test Test}
\subsubsection{Test Test Test}
\end{document}
Note: As your document will be in 12pt, I used \normalsize
to get the sectioning headings to 12pt.
Both "issues" seem to originate from the latest version of elsarticle
. At some time, your LaTeX distribution may have updated elsarticle
to the faulty version, which would explain why the issues weren't there in the beginning.
Missing section header
The issue has already been discussed there. I quote the answer:
elsarticle.cls ends with
\@ifpackageloaded{amsrefs}%
{}
{\let\bibsection\relax%
\AtBeginDocument{\def\cites@b#1#2,#3{%
\begingroup[%
\toks@{\InnerCite{#2}#1}%
\ifx\@empty#3\@xp\@gobble\fi
\cites@c#3%
}}}
This is what makes the heading disappear, since natbib redefines
the thebibliography environment to start with \bibsection, which
is responsible for the typesetting of the bibliography heading.
I don't know if this is a design decision or simply a mistake.
To recover natbib's definition of \bibsection you may try to
write
\newcommand\bibsection{%
\section*{\bibname\markright{\MakeUppercase{\bibname}}}}
in the preamble of your document. It's \newcommand and not
\renewcommand as one might expect.
The link above also points to an updated version of elsarticle
from 2011, which also fixes the issue: http://download.river-valley.com/elsarticle/elsarticle-v1.21-ELS.zip.
However, although the updated package seems to originate from the official elsarticle
developers, it hasn't been uploaded to the CTAN, or MikTeX package manager for example, which still use the faulty 2009 version.
Bibliography font size
Not sure if it's an issue. elsarticle
redefines the bibliography font size for options 1p
, 3p
and 5p
:
\global\let\bibfont=\footnotesize
You can change it by adding to your preamble:
\let\bibfont\small
or whatever font size you want.
Fixed example
\documentclass[preprint,1p,times]{elsarticle}
\newcommand\bibsection{\section*{\bibname\markright{\MakeUppercase{\bibname}}}}
\let\bibfont\small
\begin{document}
\begin{thebibliography}{9}
\bibitem{myref2003} 2003, my reference
\end{thebibliography}
\end{document}
which gives:
or, with the updated elsarticle
class (to make it quick, you can extract the elsarticle.cls
file and add it in the same folder as your .tex
file):
\documentclass[preprint,1p,times]{elsarticle}
\let\bibfont\small
\begin{document}
\begin{thebibliography}{9}
\bibitem{myref2003} 2003, my reference
\end{thebibliography}
\end{document}
Best Answer
If you are sure that you are using the
article
document class, just adding the following lines in your preamble should work:MWE
Output:
If you also want to remove the spacing add
\vspace*{-.8\baselineskip}
in the above definition, so to haveOutput: