0

MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amsfonts,amssymb,amsbsy,amsmath}
\usepackage{tocloft}
\usepackage{times}
\usepackage{titlesec, titleps titletoc}

%%\titleformat{command}[shape]{format}{label}{sep}{before-code}[after-code]
\titleformat{\paragraph}[runin]{\normalsize \rmfamily}{\theparagraph.}{1em}{}[]
\titleformat{\section}{\centering\normalsize}{ARTICLE \thesection}{1em}{\uppercase} %
\titleformat{\subsection}[runin]{\normalsize \rmfamily}{Section \thesubsection.}{1em}{\underline}[. \;]
\titleformat{\subsubsection}[runin]{\normalsize \rmfamily}{\thesubsubsection}{1em}{}[]

\renewcommand\cftsecfont{ARTICLE \uppercase}
\renewcommand\cftsubsecfont{Section }

\begin{document}

\tableofcontents % Breaks at this line

\section{Defined terms; rules of construction}
\section{Organization of partnership}
\subsection{Formation}
\subsection{Name}
\subsection{Certificates and licenses}
\subsubsection{Optional}

\end{document}

MWE output (using overleaf):

enter image description here

Notes:

Based on compile errors, the problem lies here I believe. Something to do with missing {}s.

\titleformat{\section}{\centering\normalsize}{ARTICLE \thesection}{1em}{\uppercase} %
\titleformat{\subsection}[runin]{\normalsize \rmfamily}{Section \thesubsection.}{1em}{\underline}[. \;]

Desired output (using overleaf):

Which I achieve unless I try inserting a TOC. Overleaf allows you to view this output with compile errors. But attempting to export to PDF via LyX you get: There was an error opening this document. The file is damaged and could not be repaired.

enter image description here

  • 1
    \usepackage{titlesec, titleps titletoc} ---> \usepackage{titlesec, titleps, titletoc} – flav Dec 11 '18 at 6:29
  • @flav nice catch, thanks! unfortunately, i'm still getting those compile errors. "! Missing { inserted. <to be read again> \hbox l.2 ...mberline {2}Organization of partnership}{1}" – jed Dec 11 '18 at 6:47
  • 1
    with pdflatex it's work fine ; how do you compile ? – flav Dec 11 '18 at 6:57
  • my apologies, maybe try compiling again after uncommenting \tableofcontents? I have it commented in my MWE, i'll fix that – jed Dec 11 '18 at 7:06
  • 1
    Try loading \usepackage[pagestyles]{titlesec}, not \usepackage{titleps,titleps}. – Bernard Dec 11 '18 at 9:42
0

Thank you to @flav and @Bernard, you two were correct to note that that was an issue. I also found that I messed up the structure of the \titleformat command which I figured out upon re-reading the titlesec package PDF: \titleformat{command}[shape]{format}{label}{sep}{before-code}[after-code]

The MWE solution that should create the first image without any compile errors:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amsfonts,amssymb,amsbsy,amsmath}
\usepackage{times}
\usepackage{titlesec, titleps, titletoc}

%%\titleformat{command}[shape]{format}{label}{sep}{before-code}[after-code]
\titleformat{\paragraph}[runin]{\normalsize}{\theparagraph}{1em}{}[] %
\titleformat{\section}[display]{\centering\normalsize} 
{ARTICLE\space\thesection}{1em}{\uppercase}[] %
\titleformat{\subsection}[runin]{\normalsize}{Section\space\thesubsection}{1em}{\underline}[.\;] %
\titleformat{\subsubsection}[runin]{\normalsize}{\thesubsubsection}{1em}{\underline}[.\;] %

\usepackage{tocloft}
\renewcommand\cftsecfont{ARTICLE \uppercase}
\renewcommand\cftsubsecfont{Section }

\begin{document}

\tableofcontents

\section{Defined terms; rules of construction}
\section{Organization of partnership}
\subsection{Formation}
\subsection{Name}
\subsection{Certificates and licenses}
\subsubsection{Optional}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.