为什么我的文档中的所有段落都没有缩进?

为什么我的文档中的所有段落都没有缩进?

我正在 Overleaf 中处理文档,但所有段落均未缩进。我不明白是什么强制了这种行为,因为 Latex 默认在每个部分的第一个段落后缩进段落。这是我的序言:

% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
%\documentclass[
%]{book}
\documentclass[a5paper,pagesize,10pt,bibtotoc,pointlessnumbers,    
normalheadings,DIV=9,twoside=false]{scrbook}    
\usepackage[portuguese]{babel}
\usepackage{csquotes}
\usepackage{url}
\usepackage{pdfpages}
\usepackage{appendix}
\usepackage{trajan}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{iftex}
\usepackage{graphicx}
\usepackage[margin=1in, paperwidth=6in, paperheight=9in]{geometry}
\ifPDFTeX
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
  \usepackage{unicode-math}
  \defaultfontfeatures{Scale=MatchLowercase}
  \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
  \usepackage[]{microtype}
  \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
  \IfFileExists{parskip.sty}{%
   \usepackage{parskip}
  }{% else
   \setlength{\parindent}{20pt}
   \setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
  \KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
%\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newlength{\cslentryspacingunit} % times entry-spacing
\setlength{\cslentryspacingunit}{\parskip}
\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing
 {% don't indent paragraphs
  \setlength{\parindent}{0pt}
  % turn on hanging indent if param 1 is 1
  \ifodd #1
  \let\oldpar\par
  \def\par{\hangindent=\cslhangindent\oldpar}
  \fi
  % set entry spacing
 \setlength{\parskip}{#2\cslentryspacingunit}
 }%
 {} 

\usepackage{calc}

\newcommand{\CSLBlock}[1]{#1\hfill\break}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
\ifLuaTeX
  \usepackage{selnolig}  % disable illegal ligatures
\fi
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same} % disable monospaced font for URLs
\hypersetup{
  hidelinks,
  pdfcreator={LaTeX via pandoc}}

答案1

问题如下:

\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
  \IfFileExists{parskip.sty}{%
   \usepackage{parskip}
  }{% else
   \setlength{\parindent}{20pt}
   \setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
  \KOMAoptions{parskip=half}}
\makeatother

告诉 LaTeX 你想要非零 parskip 并且没有缩进,因为你说如果该类是 KOMA 套件之一,那么parskip=half必须遵守该选项。

但我最后看到序言是由 生成的pandoc绝不在独立的 LaTeX 文档中使用这样的前言。该程序pandoc应该与较旧的 TeX 发行版兼容,因此生成的前言充满了“后备”。

该代码还具有旧式 KOMA 选项并发出非常烦人的警告。

这是一个清理过的版本。

\documentclass[
  a5paper,
  pagesize,
  10pt,
  bibliography=totoc,% <-- changed
  numbers=noenddot, % <-- changed
  headings=normal, % <-- changed
  %DIV=9,
  twoside=false,
  %parskip=half,
]{scrbook}

\usepackage[portuguese]{babel}
\usepackage{csquotes}
\usepackage{url}
\usepackage{pdfpages}
\usepackage{appendix}
\usepackage{trajan}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{iftex}
\usepackage{graphicx}
\usepackage{calc}
\usepackage[margin=1in, paperwidth=6in, paperheight=9in]{geometry}

\ifPDFTeX
  \usepackage[T1]{fontenc}
  %\usepackage[utf8]{inputenc}
  %\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
  \usepackage{unicode-math}
  \defaultfontfeatures{Scale=MatchLowercase}
  %\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\usepackage{upquote}
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts

\usepackage{xcolor}
\ifLuaTeX
  \usepackage{selnolig}  % disable illegal ligatures
\fi

\usepackage[hyphens]{xurl}
\usepackage[unicode]{hyperref}
\usepackage{bookmark}

\hypersetup{
  hidelinks,
}


\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}%
}
%\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newlength{\cslentryspacingunit} % times entry-spacing
\setlength{\cslentryspacingunit}{\parskip}
\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing
 {% don't indent paragraphs
  \setlength{\parindent}{0pt}
  % turn on hanging indent if param 1 is 1
  \ifodd #1\relax
    \def\par{\hangindent=\cslhangindent\endgraf}
  \fi
  % set entry spacing
 \setlength{\parskip}{#2\cslentryspacingunit}
 }%
 {} 


\newcommand{\CSLBlock}[1]{#1\hfill\break}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}

\usepackage{lipsum}% just to fill pages

\begin{document}

\chapter{Introduction}

\lipsum

\end{document}

在此处输入图片描述

您会看到,通过注释掉该parskip=half选项,段落确实缩进。

相关内容