TransWikia.com

Weird behavior when formatting pages

TeX - LaTeX Asked on April 10, 2021

The code below compiles to a pdf with an empty page after the TOC and the document stops at page 3, with extra text overflowing the page.

This is a very weird behavior I have never encountered before with the same set of preamble settings. Would appreciate if someone could explain why this is happening.

The Code:

% Created 2020-10-08 Thu 00:38
% Intended LaTeX compiler: pdflatex

documentclass[12pt,a4paper]{article}
%documentclass[12pt,a4paper]{ctexart}

usepackage{xeCJK}
usepackage{zhnumber} % package for Chinese formatting of date time (use /zhtoday)
usepackage[yyyymmdd]{datetime} % set date time to numeric

% For Generation of Citations and Bibliography
usepackage[notes, isbn=false, backend=biber]{biblatex-chicago}
bibliography{/Users/satibodhi/Creation/notes/bibliography/thesis}

% Set default indentation

setlengthparindent{24pt}

% Set Paper Size, Page Layout (another variable is 'bindingoffset')
usepackage[margin = 1.5in, paper = a4paper, inner = 2.5cm,
outer = 2.5cm, top = 3cm, bottom = 2.5cm]{geometry}

% Keep paragraph indentation while having a line break in between paragraphs.
edefrestoreparindent{parindent=theparindentrelax}
usepackage{parskip}
restoreparindent

% Indent first paragraph.
usepackage{indentfirst}

usepackage{titlesec}
usepackage{titling}
usepackage{fontspec} % packages for title and section-heading font setting.
usepackage{newunicodechar} % custom fallback font for certain unicode characters.
usepackage{tocloft} % adding the tocloft package for toc customization

% Set Header and Numbering Depth
setcounter{tocdepth}{5}
setcounter{secnumdepth}{5}

% Set Font.
setsansfont{Times New Roman}
setmainfont{Calibri} % Set serifed font to Calibri. Originally set to 'Times New Roman', but it cannot display certain characters such as ①②③.
setCJKmainfont{Songti TC}
setCJKsansfont{Kaiti TC} % Set Chinese font. NOTE: Remember to append CJK before of the font class. CJK HAS to be there for the font to show.
setCJKmonofont{PingFang TC}

% Set fallback fonts for ㊀ characters.

newCJKfontfamilyfallbackfont{PingFang TC}
newunicodechar{㊀}{{fallbackfont ㊀}}
newunicodechar{㊁}{{fallbackfont ㊁}}
newunicodechar{㊂}{{fallbackfont ㊂}}
newunicodechar{㊃}{{fallbackfont ㊃}}
newunicodechar{㊄}{{fallbackfont ㊄}}
newunicodechar{㊅}{{fallbackfont ㊅}}
newunicodechar{㊆}{{fallbackfont ㊆}}
newunicodechar{㊇}{{fallbackfont ㊇}}
newunicodechar{㊈}{{fallbackfont ㊈}}
newunicodechar{㊉}{{fallbackfont ㊉}}

% WHEN documentclass is set to {article},
% zhnum[style={Traditional,Financial}] doesn't work with the section counter,
% so we define our own counter and increase it every time in thesection.

newcounter{mysec}[section]
renewcommandthesection{%
    addtocounter{mysec}{1}%
    zhnum[style={Traditional,Financial}]{mysec}、} % 大標題序號:壹、貳、參、…
renewcommandthesubsection{zhnum{subsection}、} % added a 、小標題序號:一、二、三、…
renewcommandthesubsubsection{(zhnum{subsubsection})} % added parentheses
% (full-width, don't know if that's what you want) 副標題序號:(一)(二)(三)
renewcommandtheparagraph{arabic{paragraph}} % arabic numbering for paragraph
renewcommandthesubparagraph{} % no subparagraph numbering

% we have to adjust the spacing in the toc because the section label is longer than usual
addtolengthcftsecnumwidth{1em}
addtolengthcftsubsecindent{1em}
addtolengthcftsubsubsecindent{1em}

% Set formats for each heading level. 'sffamily' will point to the sans-serif font. In this case, 「楷體」.

% here we need to make sure the normal section counter is accessed
titleformat{section}{LARGEbfseriessffamilyfilcenter}
    {zhnum[style={Traditional,Financial}]{section}、}{.5em}{}

titleformat*{subsection}{Largebfseriessffamily}
titleformat*{subsubsection}{largebfseriessffamily} % Set formats for each heading level. 'sffamily' will point to the sans-serif font. In this case, 「楷體」.

% The `titlesec` package is used over here to make use of `paragraph` and `subparagraph` as headings. Up to five levels of headings can be implemented this way.

% no extra version for numberless is necessary since no numbers are used anyways
% also you get newlines from omitting the [display] in titleformat already
titleformat{paragraph}[block]
    {largebfseriessffamily}{theparagraph}{0em}{}
titleformat{subparagraph}[block]
    {largebfseriessffamily}{}{0em}{}
% we need the following so that they don't indent (second argument, 0em);
% you'll have to adjust the spacing though since this is not display style anymore:
titlespacing*{paragraph}{0em}{3.25ex plus 1ex minus .2ex}{.75ex plus .1ex}
titlespacing*{subparagraph}{0em}{3.25ex plus 1ex minus .2ex}{.75ex plus .1ex}

% Set title font.
renewcommand{maketitlehooka}{sffamily}

% Set quotation font.
usepackage{etoolbox}
newCJKfontfamilyquotefont{Kaiti TC}
AtBeginEnvironment{quote}{quotefontnormalsize}

% Tweak default settings.
renewcommand{baselinestretch}{1.2} % Set line width.
renewcommand{contentsname}{hfillbfseriesLarge 目hspace{0.5cm} 錄hfill} % Translate content page title to Chinese.
renewcommand{cftaftertoctitle}{hfill} % Center contents title.
renewcommand{abstractname}{摘要} % Translate abstract title to Chinese.
renewcommand{tablename}{表} % Translate table to Chinese.
renewcommand{figurename}{圖} % Translate figure to Chinese.

% For text-boxes

usepackage{mdframed}
BeforeBeginEnvironment{minted}{begin{mdframed}}
AfterEndEnvironment{minted}{end{mdframed}}

% For tables

usepackage{float}
restylefloat{table}

% [FIXME] ox-latex 的設計不良導致 hypersetup 必須在這裡插入
usepackage{hyperref}
hypersetup{
  colorlinks=true, %把紅框框移掉改用字體顏色不同來顯示連結
  linkcolor=[rgb]{0,0.37,0.53},
  citecolor=[rgb]{0,0.47,0.68},
  filecolor=[rgb]{0,0.37,0.53},
  urlcolor=[rgb]{0,0.37,0.53},
  pagebackref=true,
  linktoc=all,}

usepackage{hyperref}
usepackage{graphicx}
usepackage{longtable}
usepackage{wrapfig}
usepackage{rotating}
usepackage[normalem]{ulem}
usepackage{amsmath}
usepackage{textcomp}
title{Annotated Bibliography Sample}
begin{document}

maketitle
tableofcontents clearpage
section{情感教育理論}
label{sec:org4e5e8b3}

subsection{儒學史脈絡中的道德情感理論}
label{sec:org7731e3f}

subsubsection*{Nivison, D. S. (1996). The ways of confucianism: investigations in Chinese philosophy. Chicago: Open Court.}
label{sec:org89a9863}



subsubsection*{Shun, K. (1997). Mencius and early Chinese thought. Stanford, Calif: Stanford University Press.}
label{sec:org9a03f46}


subsubsection*{Virág, C. (2004). "That which encompasses the Myriad cares": Subjectivity, knowledge, and the ethics of emotion in Tang and Song China (Doctoral dissertation). Harvard University.}
label{sec:orge4c47c9}


subsubsection*{Chan, A. K. (2007). The Nature of the Sage and the Emotions: A Debate in Wei-Jin Philosophy Revisited. Journal of Chinese Philosophy and Culture 2, 196–226.}
label{sec:org258739b}


subsubsection*{Kim, M. (2008): An inquiry into the development of the ethical theory of emotions in the "Analects" and the "Mencius"}
label{sec:orga5bd938}


subsubsection*{Lo, Y. K. (2012). Mind-Heart and Emotions in the Analects. In G. Tamburello (Eds.), Concepts and Categories of Emotion in East Asia (pp. 71–86). Rome: Carocci editore.}
label{sec:org60c7db6}


subsubsection*{Virág, C. (2014). Early confucian perspectives on emotions. In V. Shen (Eds.), Dao Companion to Classical Confucian Philosophy (pp.203–225). : Springer, Dordrecht.}
label{sec:orge2be0cd}


subsubsection*{Virág, C. (2017). The emotions in early Chinese philosophy. New York, NY: Oxford University Press.}
label{sec:org2e3eedf}


subsection{心理學對情感的認知}
label{sec:org8023f3a}

subsubsection*{Griffiths, P. E. (1997). What emotions really are: the problem of psychological categories. Chicago, Ill.: University of Chicago Press.}
label{sec:orgf4a2034}

section{羞愧感研究}
label{sec:org3238d23}

subsection{羞愧與同理心}
label{sec:org47b3841}

subsubsection*{Zahavi, D. (2015). Self and other exploring subjectivity, empathy and shame. Corby: Oxford University Press.}
label{sec:org9dbac8f}

subsubsection*{Stearns, P. N. (2017). Shame: a brief history. Urbana, Illinois: University of Illinois Press.}
label{sec:orgb1ba550}
end{document}

The Result:

Weird Results

One Answer

Following @Mico's instruction from the comments above, adding null to each empty subsection fixes the problem.

begin{document}

maketitle
tableofcontents clearpage
section{情感教育理論}
label{sec:org4e5e8b3}

subsection{儒學史脈絡中的道德情感理論}
label{sec:org7731e3f}

subsubsection*{Nivison, D. S. (1996). The ways of confucianism: investigations in Chinese philosophy. Chicago: Open Court.}
label{sec:org89a9863}

null

subsubsection*{Shun, K. (1997). Mencius and early Chinese thought. Stanford, Calif: Stanford University Press.}
label{sec:org9a03f46}

null

subsubsection*{Virág, C. (2004). "That which encompasses the Myriad cares": Subjectivity, knowledge, and the ethics of emotion in Tang and Song China (Doctoral dissertation). Harvard University.}
label{sec:orge4c47c9}

null

subsubsection*{Chan, A. K. (2007). The Nature of the Sage and the Emotions: A Debate in Wei-Jin Philosophy Revisited. Journal of Chinese Philosophy and Culture 2, 196–226.}
label{sec:org258739b}

null

subsubsection*{Kim, M. (2008): An inquiry into the development of the ethical theory of emotions in the "Analects" and the "Mencius"}
label{sec:orga5bd938}

null

subsubsection*{Lo, Y. K. (2012). Mind-Heart and Emotions in the Analects. In G. Tamburello (Eds.), Concepts and Categories of Emotion in East Asia (pp. 71–86). Rome: Carocci editore.}
label{sec:org60c7db6}

null

subsubsection*{Virág, C. (2014). Early confucian perspectives on emotions. In V. Shen (Eds.), Dao Companion to Classical Confucian Philosophy (pp.203–225). : Springer, Dordrecht.}
label{sec:orge2be0cd}

null

subsubsection*{Virág, C. (2017). The emotions in early Chinese philosophy. New York, NY: Oxford University Press.}
label{sec:org2e3eedf}

null

subsection{心理學對情感的認知}
label{sec:org8023f3a}

subsubsection*{Griffiths, P. E. (1997). What emotions really are: the problem of psychological categories. Chicago, Ill.: University of Chicago Press.}
label{sec:orgf4a2034}

null

section{羞愧感研究}
label{sec:org3238d23}

subsection{羞愧與同理心}
label{sec:org47b3841}

subsubsection*{Zahavi, D. (2015). Self and other exploring subjectivity, empathy and shame. Corby: Oxford University Press.}
label{sec:org9dbac8f}

null

subsubsection*{Stearns, P. N. (2017). Shame: a brief history. Urbana, Illinois: University of Illinois Press.}
label{sec:orgb1ba550}

null

end{document}

Result:

Okay Result

Correct answer by Sati on April 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP