
在我的專案中,我使用這些包\usepackage{sectsty}
和\usepackage{titlesec}
.
然而,每當我將一個部分放入中心環境時,例如“第一句話”,我得到的輸出就會根據每個單字“The”、“first”、“saying”之間的空格進行擴展,從而完全填滿該行及其空間。
我該如何解決這個問題?謝謝。
\documentclass[13pt,a4paper]{report}
\usepackage[utf8]{inputenc, vietnam}
\usepackage[left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\usepackage{sectsty}
\usepackage{titlesec}
\begin{document}
\begin{center}
\section*{The first saying}
\end{center}
\end{document}
答案1
根據我的經驗,同時加載宗派和標題安全禮貌地說,可能會導致意想不到的結果。 AFAICT,加載這兩個包從來沒有充分的理由。選擇其中之一,但不是兩者都。
我不清楚您想要實現哪個格式化目標。如果要居中設定節級標題,請不要在指令中包含\section
和/或\section*
指令。center
相反,只需執行序言中的以下指令
\usepackage{sectsty}
\sectionfont{\centering}
然後在文檔正文中運行\section
和 ,而不將它們放置在環境中。\section*
center
下面螢幕截圖中的框架線之所以存在,是因為我已經使用選項載入了幾何套件showframe
。
\documentclass[12pt,a4paper]{report} % 13pt is not a valid option
%\usepackage[utf8]{inputenc} % that's the default nowadays
\usepackage[T1]{fontenc}
\usepackage[vietnamese]{babel}
\usepackage{lmodern}
\usepackage[margin=3cm,showframe]{geometry}
\usepackage{sectsty}
\sectionfont{\centering}
\begin{document}
\section*{Chào buổi sáng mọi người}
\end{document}