Text FormattingAdd a line above/below the section title

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
jjmm
Posts: 13
Joined: Tue Jul 12, 2016 5:23 am

Add a line above/below the section title

Post by jjmm »

Hi,

(1) I manage to add a line above and below the title. I modify some codes I search from the web, and I can only add a line below the title, but I do not know how to add a line above the section title. Could someone show me how to do it?
(2) Another thing I would like to do is to add a dot after the section number, e.g., I would like "3. The application of ......", but I have "3 The application of ......" Thanks!

The core codes are as follows:

Code: Select all

\usepackage[explicit]{titlesec}
\definecolor{Blue}{rgb}{0,0,0.8}
.......
\titleformat{\section}
{\normalfont\large\bfseries\color{Blue}}
{\titlerule\vspace{1pc}\thesection}
{1em}
{#1}
[{\titlerule[0.8pt]}] 


Complete codes:

Code: Select all

\documentclass[11pt]{article}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{graphicx}
\usepackage[margin=1in]{geometry}
\usepackage{fancyhdr}
\usepackage[shortlabels]{enumitem}
\usepackage{enumitem}
\usepackage{xcolor}
\usepackage[explicit]{titlesec}
\definecolor{Blue}{rgb}{0,0,0.8}
\setlength{\parindent}{0pt}
\setlength{\parskip}{5pt plus 1pt}
\setlength{\headheight}{13.6pt}

\numberwithin{equation}{section} 

\titleformat{\section}
{\normalfont\large\bfseries\color{Blue}}
{\titlerule\vspace{1pc}\thesection}
{1em}
{#1}
[{\titlerule[0.8pt]}]


\newcommand\question[2]{\vspace{.25in}\hrule\textbf{#1. #2}\vspace{.5em}\hrule\vspace{.10in}}
\renewcommand\part[1]{\vspace{.10in}\textbf{(#1)}}
\pagestyle{fancyplain}
\lhead{\textbf{\NAME}}
\chead{\textbf{Econ 100A HW\HWNUM}}
\rhead{\today}
\begin{document}\raggedright

\newcommand\NAME{John Smith}  
\newcommand\HWNUM{3}              
\section{First section}
\section{Lucas puzzle}
\section{The Application of}
\section{Capital Control and NDF}
xxxx
\section{Cagan variant and exchange rates}
\begin{enumerate}[(a)]
	\item\item  Cagan model
	\begin{eqnarray}
m_t-p_t=-\eta i_{t+1}+\phi y_t,	
	\end{eqnarray}
	where money demand 
\end{enumerate}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Add a line above/below the section title

Post by cgnieder »

site moderator & package author
Post Reply