LaTeX forum ⇒ Text FormattingAdd a line above/below the section title

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

Add a line above/below the section title

Postby jjmm » Tue Jul 12, 2016 5:36 am

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:

  1. \usepackage[explicit]{titlesec}
  2. \definecolor{Blue}{rgb}{0,0,0.8}
  3. .......
  4. \titleformat{\section}
  5. {\normalfont\large\bfseries\color{Blue}}
  6. {\titlerule\vspace{1pc}\thesection}
  7. {1em}
  8. {#1}
  9. [{\titlerule[0.8pt]}]


Complete codes:

  1. \documentclass[11pt]{article}
  2. \usepackage{amsmath,amssymb,amsthm}
  3. \usepackage{graphicx}
  4. \usepackage[margin=1in]{geometry}
  5. \usepackage{fancyhdr}
  6. \usepackage[shortlabels]{enumitem}
  7. \usepackage{enumitem}
  8. \usepackage{xcolor}
  9. \usepackage[explicit]{titlesec}
  10. \definecolor{Blue}{rgb}{0,0,0.8}
  11. \setlength{\parindent}{0pt}
  12. \setlength{\parskip}{5pt plus 1pt}
  13. \setlength{\headheight}{13.6pt}
  14.  
  15. \numberwithin{equation}{section}
  16.  
  17. \titleformat{\section}
  18. {\normalfont\large\bfseries\color{Blue}}
  19. {\titlerule\vspace{1pc}\thesection}
  20. {1em}
  21. {#1}
  22. [{\titlerule[0.8pt]}]
  23.  
  24.  
  25. \newcommand\question[2]{\vspace{.25in}\hrule\textbf{#1. #2}\vspace{.5em}\hrule\vspace{.10in}}
  26. \renewcommand\part[1]{\vspace{.10in}\textbf{(#1)}}
  27. \pagestyle{fancyplain}
  28. \lhead{\textbf{\NAME}}
  29. \chead{\textbf{Econ 100A HW\HWNUM}}
  30. \rhead{\today}
  31. \begin{document}\raggedright
  32.  
  33. \newcommand\NAME{John Smith}
  34. \newcommand\HWNUM{3}
  35. \section{First section}
  36. \section{Lucas puzzle}
  37. \section{The Application of}
  38. \section{Capital Control and NDF}
  39. xxxx
  40. \section{Cagan variant and exchange rates}
  41. \begin{enumerate}[(a)]
  42. \item\item Cagan model
  43. \begin{eqnarray}
  44. m_t-p_t=-\eta i_{t+1}+\phi y_t,
  45. \end{eqnarray}
  46. where money demand
  47. \end{enumerate}
  48. \end{document}

Tags:

User avatar
cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Tue Oct 04, 2016 3:53 pm

Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 7 guests