我正在使用 LaTeX 写学习笔记。我想用一个标题来介绍我将要讨论的内容。我不希望:文本为粗体,标题为编号。有什么方法可以实现这一点吗?哦,还有,我希望标题和正文之间的间距合适。这是我目前正在做的一个例子,即我使用 center 环境以及 vspace。
我的代码:
\begin{center} This is what I'd like to have \end{center}
Find more information about how to ask a good question here. Visit the help center. Ask questions about the site on meta
\vspace{2mm}
\begin{center} This is what I'd like to have \end{center}
Find more information about how to ask a good question here. Visit the help center. Ask questions about the site on meta
答案1
像这样吗?
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{titlesec}%
\titleformat{\section}[block]{\filcenter\Large\scshape}{}{0ex}{}
\titlespacing*{\section}{0pt}{10ex}{6ex}
\begin{document}
\section{ This is what I'd like to have}
Find more information about how to ask a good question here. Visit the help center. Ask questions about the site on meta.
\section{This is also what I'd like to have}
Find more information about how to ask a good question here. Visit the help center. Ask questions about the site on meta.
\end{document}
答案2
我建议坚持使用基本标记,因为它允许您在将来以全局(简单)的方式更改事物,而不必找到每个\begin{center}
...\end{center}
构造来更改某些内容。
下面我使用sectsty
更改章节标题的格式/样式并删除章节编号。这样,\section{...}
仍然可以防止在页面底部被孤立,同时您的center
构造可能会与其内容分离。
\documentclass{article}
\usepackage{sectsty}
\sectionfont{\normalfont\large}% Section font styling
\makeatletter
\renewcommand{\@seccntformat}[1]{}% Remove section numbering
\makeatother
\begin{document}
\section{This is what I'd like to have}
Find more information about how to ask a good question here.
Visit the help center. Ask questions about the site on meta
\section{This is what I'd like to have}
Find more information about how to ask a good question here.
Visit the help center. Ask questions about the site on meta
\end{document}