使用 wordlike 时如何换行章节标题?

使用 wordlike 时如何换行章节标题?

我有一个基于该wordlike包的模板。当我有一个较长的章节标题时,它会超出页面边缘,而不是换行(例如)代码如下:

\documentclass[12pt]{article}

% Emulate MS Word
\usepackage{wordlike}

% One inch margins
\PassOptionsToPackage{margin=1in}{geometry}

% Double spacing
\usepackage{setspace}
\setstretch{2}

% Don't justify along the right margin
\usepackage{ragged2e}
\RaggedRight

% Format section titles
\usepackage[uppercase]{titlesec}
\titlespacing\section{0pt}{0pt}{7pt}
\usepackage{titlesec}
\titleformat{\section}
    {\normalfont\bf\center\uppercase}{\underline{\thesection.\ 
    }}{1em}{\underline}

% Format paragraphs
\parskip 0pt
\setlength{\parindent}{0.5in}

% Remove section numbers
\setcounter{secnumdepth}{-2}

\begin{document}

\section{Here's an example of a long section title that is going to stretch beyond the page}

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

\end{document}

如果我尝试使用 强制换行\\,我会收到此错误:Something's wrong--perhaps a missing \item.

答案1

问题不在于wordlike;标准\underline不允许换行;而是使用\ulinefrom ulem

\documentclass[12pt]{article}

% Emulate MS Word
\usepackage{wordlike}
\usepackage[normalem]{ulem}

% One inch margins
\PassOptionsToPackage{margin=1in}{geometry}

% Double spacing
\usepackage{setspace}
\setstretch{2}

% Don't justify along the right margin
\usepackage{ragged2e}
\RaggedRight

% Format section titles
\usepackage[uppercase]{titlesec}
\titlespacing\section{0pt}{0pt}{7pt}
\usepackage{titlesec}
\titleformat{\section}
    {\normalfont\bfseries\filcenter}{\uline{\thesection.\ }}{0em}{\uline}

% Format paragraphs
\parskip 0pt
\setlength{\parindent}{0.5in}

% Remove section numbers
\setcounter{secnumdepth}{-2}

\begin{document}

\section{Here's an example of a long section title that is not going to stretch beyond the page due to the changes}

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

\end{document}

在此处输入图片描述

使用粗体下划线标题似乎是多余的,而且不是一个很好的做法。

相关内容