段落前留出空格

段落前留出空格

我想在我的代码的任何段落之前添加一个制表符:

\documentclass[a4paper,12pt]{report}
\usepackage[a4paper, inner=2cm, outer=3cm, top=2cm,
bottom=3cm, bindingoffset=1cm,headsep=5pt]{geometry}
\usepackage[utf8]{inputenc}
%\usepackage{upquote}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{hyperref}
\hypersetup{colorlinks,%
citecolor=black,%
filecolor=black,%
linkcolor=black,%
urlcolor=black,%
pdftex}
\usepackage{listings}
\usepackage{color}

\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

\lstset{frame=tb,
  language=Java,
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  columns=flexible,
  basicstyle={\small\ttfamily},
  numbers=none,
  numberstyle=\tiny\color{gray},
  keywordstyle=\color{blue},
  commentstyle=\color{dkgreen},
  stringstyle=\color{mauve},
  breaklines=true,
  breakatwhitespace=true,
  tabsize=3
}
\usepackage[english]{babel}
\usepackage[english]{layout}
\usepackage{tikz}
\renewcommand{\thechapter}{\Roman{chapter}}
\usepackage{pifont}
\usepackage{fancyhdr}
\renewcommand{\baselinestretch}{1.5}
\renewcommand{\lstlistingname}{Code}
\pagestyle{fancy}
\fancyhf{}
\rhead{\thepage}
\usepackage{float}
\lhead{\textit{\nouppercase\leftmark }}
\setcounter{secnumdepth}{5}
%\usepackage{titlesec}
%\usepackage{titletoc}

% Ajustement de l'espace dans la table des matières
\newlength{\ecartnumero}
\setlength{\ecartnumero}{4mm}

%\dottedcontents{figure}%
%  [\dimexpr 7mm+\ecartnumero]{}
%  {\dimexpr 7mm+\ecartnumero}{1.2mm}


\setlength{\parskip}{1em}
\begin{document}
     xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx . 
   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
\end{document}

他打印:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx . 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

我想在段落前添加制表符,例如:

   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx . 
   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

答案1

要创建段落分隔符,请在文本行之间留出一个或多个空行

我已经从序言中删除了所有与创建段落无关的代码。

在此处输入图片描述

从屏幕截图中可以看出,普通段落的第一行会自动缩进(缩进量为\parindent,长度变量)。如果您还想缩进紧随\chapter、、等之后\section的段落的第一行,请加载包,正如@GustavoMezzetti 已经在评论中指出的那样。\subsectionindentfirst

\documentclass[a4paper,12pt]{report}
\usepackage[inner=2cm, outer=3cm, top=2cm,
        bottom=3cm, bindingoffset=1cm,
        headsep=5pt]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\rhead{\thepage}
\lhead{\textit{\nouppercase\leftmark }}
\renewcommand{\baselinestretch}{1.5}
\setlength{\parskip}{1em}

\begin{document}
xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxx xxxxxxxxxx
xxxxxxxxxx xxx xxxx xxxxx xxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxx. 

xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxx xxxxxxxxxx
xxxxxxxxxx xxx xxxx xxxxx xxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxx. 
\end{document}

相关内容