Underline subsections
I'd like to propose a different approach, using the titlesec
package. The reason is the the standard \underline
command used in the other answer doesn't support line breaks, so one could end up with undesired results for long titles, as the following example illustrates:
\documentclass[11pt]{article}
\usepackage{sectsty}
\subsectionfont{\normalfont\large\itshape\underline}
\begin{document}
\section*{Materials and Methods}
\subsection*{Sampling and some other words just to show what might go wrong with a long title for a subsection}
Lorem ipsum
\end{document}
Using the explicit
option for titlesec
, you have easy access to the title, and the \uline
command from the ulem
package (for example) can be used, so that now line breaks are allowed:
\documentclass[11pt]{article}
\usepackage[explicit]{titlesec}
\usepackage{ulem}
\titleformat{\subsection}
{\normalfont\large\itshape}{\thesubsection}{1em}{\uline{#1}}
\begin{document}
\section*{Materials and Methods}
\subsection*{Sampling and some other words just to show what might go wrong with a long title for a subsection}
Lorem ipsum
\end{document}
Enough has been said in comments and in the other answer about whether or not to underline, so I will not insist on this here.
As @egreg has pointed out, underlining is not standardly considered good practice in typography nowadays, which is just something you many want to keep in mind. Nonetheless, I don't think that should prevent you from receiving an answer to your question. If you do in fact want to underline subsections, you can do so using the sectsty
package. Here's an MWE:
Update: As @GonzaloMedina points out in the other answer, my previous answer ran into problems with long (sub)section titles that needed to break over multiple lines. The approach that uses the sectsty
package can also be remedied by loading the ulem
package with the optional [normalem]
argument. (The [normalem]
argument prevents the ulem
package from enabling the feature of the ulem
package that replaces italics with underlining of text that is emphasized with the \emph
and \em
commands.)
\documentclass[11pt]{article}
\usepackage[normalem]{ulem}
\usepackage{sectsty}
\subsectionfont{\normalfont\large\itshape\underline}
\begin{document}
\section*{Materials and Methods}
\subsection*{Sampling}
\subsection*{A very long sectional heading title that will probably have to be split over two lines}
Lorem ipsum
\end{document}