Text FormattingStrange format change overnight

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
niteshs
Posts: 45
Joined: Wed Jun 06, 2012 9:57 pm

Strange format change overnight

Post by niteshs »

Hi,

I am seeing a really weird change in the toc format this morning. Here is how it looked last night:
toc1.png
toc1.png (4.38 KiB) Viewed 6938 times
And here is how the same document looks when compiled this morning:
toc2.png
toc2.png (3.32 KiB) Viewed 6938 times
As can be seen, the spacing is messed up. In case anyone is curious, the purpose of this document was to test changing the format/style of section...paragraph headings.
The document (and the class file) is attached below. Until this morning, I had not had such a problem with the toc when using this class file before. Can someone figure out what is going on here? Thanks!
Attachments
ndsuthesis.cls
(17.01 KiB) Downloaded 490 times
prgraph.tex
(938 Bytes) Downloaded 559 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Re: Strange format change overnight

Post by cgnieder »

If such things happen the first question must always be: “What was the last thing I did?” and then undo it. If that helps you know at least to source for the problem. Have you added any package? Have you redefined some length or skip value?

Regards
site moderator & package author
niteshs
Posts: 45
Joined: Wed Jun 06, 2012 9:57 pm

Re: Strange format change overnight

Post by niteshs »

I did infact update MikTeX at some point. How do I revert these updated packages to the previous version? I only know of the uninstall option in the Package Manager (I need some of the packages for my document).
niteshs
Posts: 45
Joined: Wed Jun 06, 2012 9:57 pm

Strange format change overnight

Post by niteshs »

I have found the cause (thanks cgnieder)- now to fix it!

My initial issue was to change the default paragraph heading style. For some time I had been using:

Code: Select all

\newcommand{\para}[1]{\paragraph{#1\\*}\hspace{4mm}}
to get the style in the above example.

However I felt that my method was ugly/messy/inelegant (also the spacing after the paragraph heading was not to my liking), and tried to look for a better, nicer way to get required style. Some search led me to the following (which is used in my example):

Code: Select all

\makeatletter\renewcommand\paragraph{
\@startsection{paragraph}{4}{0mm}
{0.5\baselineskip}{0.5\baselineskip}
{\normalfont\bfseries}
}\makeatother
But using this code messed up the before/after spacing of the subsection and subsubsection headings, so I put in similar code to fix that and that is how the problem arose (I didn't catch it last night because it takes multiple runs to rebuild the toc :P )

At this point, removing the offending code has fixed the toc spacing problem, but I would still like to find a good way to change the paragraph heading style. So any suggestions for that are appreciated.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Strange format change overnight

Post by localghost »

niteshs wrote:[…] At this point, removing the offending code has fixed the ToC spacing problem, but I would still like to find a good way to change the paragraph heading style. So any suggestions for that are appreciated.
Search the forum for solutions by the titlesec package.


Thorsten
niteshs
Posts: 45
Joined: Wed Jun 06, 2012 9:57 pm

Strange format change overnight

Post by niteshs »

I tried using:

Code: Select all

\usepackage{titlesec}
\titleformat{\paragraph}{\bfseries}{\theparagraph}{1em}{}
This gave me the paragraph heading style I wanted, but messed with with all the other headings (all other heading were now un-nunmbered and un-bolded) ! Is that normal? If I use the titlesec package, do I have to format ALL existing headings to appear like they were before? That doesn't seem right :? In the titlesec examples I have found in this forum, only the specific section of interest was modified each time.

Edit: I just realized I had mentioned "to get the style in the above example" earlier in this thread, but there was no such example :oops:
Here is how the default paragraph looks:
paraold.png
paraold.png (3.72 KiB) Viewed 6915 times
And here is how I want it to look:
paranew.png
paranew.png (3.28 KiB) Viewed 6915 times
Like I mentioned, my solution \newcommand{\para}[1]{\paragraph{#1\\*}\hspace{4mm}} works, but I would like to use a "nicer" solution.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Strange format change overnight

Post by localghost »

niteshs wrote:I tried using:

Code: Select all

\usepackage{titlesec}
\titleformat{\paragraph}{\bfseries}{\theparagraph}{1em}{}
This gave me the paragraph heading style I wanted, but messed with with all the other headings (all other heading were now un-nunmbered and un-bolded) ! Is that normal? If I use the titlesec package, do I have to format ALL existing headings to appear like they were before? That doesn't seem right :? In the titlesec examples I have found in this forum, only the specific section of interest was modified each time.[…]
Do your homework and prepare a proper minimal example that clearly reproduces the undesired behaviour instead of a theoretical description.
niteshs
Posts: 45
Joined: Wed Jun 06, 2012 9:57 pm

Strange format change overnight

Post by niteshs »

I pretty much gave up on trying to use a different solution for the paragraph style when the strangeness decided to kick in again :?

I am now having problems with the subsubsection heading (it appears in line with the previous paragraph):
subsubsection.png
subsubsection.png (4.42 KiB) Viewed 6908 times
This happens only with the custom class that I have been using (with no such problems until now). To make sure everything is clean, I downloaded a fresh copy of the class file but am still seeing this problem.

Here is an mwe:

Code: Select all

\documentclass{ndsuthesis}

\usepackage{blindtext}

\usepackage{chngcntr}
\counterwithin{paragraph}{subsubsection}
\setcounter{secnumdepth}4

\begin{document}
\tableofcontents
\mainbody
\section{Introduction}
\blindtext
\subsection{Something}
\blindtext
\subsubsection{Another}
\blindtext
\paragraph{Para}
\blindtext
\paragraph{Paratwo}
\blindtext
\subsubsection{Test}
\blindtext
\subsection{Blahblah}
\blindtext
\section{second}
\blindtext
\end{document}
And the class file:
ndsuthesis.cls
(16.12 KiB) Downloaded 452 times
Incidentally, regarding my previous question about the paragraph format, using the titlesec package helped with the following:

Code: Select all

\usepackage{titlesec}
\titleformat{\paragraph}{\bfseries}{\theparagraph}{1em}{}
but only with the article class. Using the above custom class messed up everything. Adding this code to the above mwe should show this problem.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Strange format change overnight

Post by cgnieder »

This strange behaviour is a bug in the ndsuthesis class. It defines \subsubsection in line 359 like this:

Code: Select all

\renewcommand{\subsubsection}{\secdef\NDSUssseca\NDSUsssecb}
\newcommand{\NDSUssseca}[2][?]{% --> \subsubsection[toc-entry]{title}
     \refstepcounter{subsubsection}
     \noindent {\bf \thesubsubsection. #2} \par
     \addcontentsline{toc}{subsubsection}
          {\hspace{13mm}\thesubsubsection.\;\;#1}
     \addtocontents{toc}{\quad}}
\newcommand{\NDSUsssecb}[2][?]{% --> \subsubsection*[toc-entry]{title}
     \noindent {\bf #2} \par
     \ifthenelse{\equal{#1}{?}}{%
          \addcontentsline{toc}{subsubsection}{\hspace{13mm}#2}
	  \addtocontents{toc}{\quad}}{%
          \addcontentsline{toc}{subsubsection}{\hspace{13mm}#1}
	  \addtocontents{toc}{\quad}}}
The definition of \NDSUssseca (and \NDSUsssecb in case of a unnumbered subsubsection) is where things go wrong. You might want to redefine it like this:

Code: Select all

\renewcommand*{\NDSUssseca}[2][?]{% --> \subsubsection[toc-entry]{title}
     \refstepcounter{subsubsection}%
     \par \addvspace{\baselineskip}% <= new
     \noindent {\bf \thesubsubsection. #2} \par
     \addcontentsline{toc}{subsubsection}
          {\hspace{13mm}\thesubsubsection.\;\;#1}%
     \addtocontents{toc}{\quad}%
     \nobreak}% <= new
\newcommand{\NDSUsssecb}[2][?]{% --> \subsubsection*[toc-entry]{title}
     \par \addvspace{\baselineskip}% <= new
     \noindent {\bf #2} \par
     \ifthenelse{\equal{#1}{?}}{%
          \addcontentsline{toc}{subsubsection}{\hspace{13mm}#2}%
	  \addtocontents{toc}{\quad}}{%
          \addcontentsline{toc}{subsubsection}{\hspace{13mm}#1}%
	  \addtocontents{toc}{\quad}}%
	  \nobreak}% <= new
As for adapting \paragraph: you should probably define it in a similar way as the class does:

Code: Select all

\renewcommand{\paragraph}{\secdef\NDSUparaa\NDSUparab}
\newcommand{\NDSUparaa}[2][?]{% --> \paragraph[toc-entry]{title}
     \refstepcounter{paragraph}
     \par \addvspace{\baselineskip}%
     \noindent {\bf \theparagraph. #2} \par
     \addcontentsline{toc}{paragraph}
          {\hspace{13mm}\theparagraph.\;\;#1}%
     \addtocontents{toc}{\quad}%
     \nobreak}% <= new
\newcommand{\NDSUparab}[2][?]{% --> \paragraph*[toc-entry]{title}
     \par \addvspace{\baselineskip}%
     \noindent {\bf #2} \par
     \ifthenelse{\equal{#1}{?}}{%
          \addcontentsline{toc}{paragraph}{\hspace{13mm}#2}%
	  \addtocontents{toc}{\quad}}{%
          \addcontentsline{toc}{paragraph}{\hspace{13mm}#1}%
	  \addtocontents{toc}{\quad}}%
     \nobreak}
Regards

PS: It may be desirable to redefine \subsection as well. It's possible that the current definition allows page breaks between the title and the first paragraph.
site moderator & package author
niteshs
Posts: 45
Joined: Wed Jun 06, 2012 9:57 pm

Strange format change overnight

Post by niteshs »

Thanks cgnieder, I have added your definitions to the class and all seems to be working fine now.

I have a few questions though:

1) Originally, section titles appeared as expected (on their own lines). When I tried to edit the class to include a format for the paragraph title based on the other existing section titles (like you just suggested), it messed up the subsubsection titles (this was before you provided the above solution).

Commenting out, or deleting the edit did not revert things back, even getting a fresh copy of the class file did not help. So the change was somehow being propagated independent of the class file? Any idea what might be going on?

2) Why was the subsubsection affected but not subsection?

Anyway, maybe there is no way to figure out what went wrong. I am glad my document is back on track (for now ;) )- Thanks again!
Post Reply