章节和文本左缩进

章节和文本左缩进

我的 MWE:

\documentclass[a4paper,12pt]{article}
\usepackage{showframe}
\usepackage{lipsum}

\usepackage{geometry}
\geometry{paper=a4paper}                
\geometry{bindingoffset=1.5cm,hmargin={1.5cm,1.5cm},vmargin={1cm,1cm}}
\geometry{includehead=true,headheight=3cm,headsep=1cm}  
\geometry{includefoot=false}

\begin{document}
\section{Section}
\lipsum[1-1]
\subsection{Subsection}
\lipsum[1-1]
\subsubsection{Subsubsection}
\lipsum[1-1]
\end{document}

文本输出:(bindingoffset 1.5cm + 左边距 1.5cm;总左边距 3cm) 在此处输入图片描述

期望输出: 在此处输入图片描述

是否可以将章节和章节/小节等下的文本缩进 2 厘米?

编辑 在@Bernard 的帮助下: 在此处输入图片描述 是否可以将编号向左移动;就像我想要的输出一样?

编辑2(也与问题相关合并两个宏)使用@Bernard、@ereg 和@Henri Menke 代码和@cfr 建议。

代码

\documentclass[a4paper,12pt]{article}
\usepackage{lipsum}

\usepackage[showframe]{geometry}
\geometry{paper=a4paper}
\geometry{bindingoffset=1.5cm,hmargin={3.5cm,1.5cm},vmargin={1cm,1cm}}
\geometry{includehead=true,headheight=3cm,headsep=1cm}
\geometry{includefoot=false}
\usepackage{changepage}
\usepackage{titlesec}
\usepackage{etoolbox} 
\usepackage[ampersand]{easylist}
\usepackage{xcolor}

\renewcommand{\contentsname}{\hfill \textit{Table of Contents}}     %%Table of contents name change
\renewcommand{\listfigurename}{\hfill \textit{List of Figures}}     %%List of figures name change
\renewcommand{\listtablename}{\hfill \textit{List of Tables}}       %%List of tables name change
\newcommand\tocloflot{%
    \clearpage
    \tableofcontents
    \addtocontents{toc}{\hrule height1pt}
    \clearpage
    \csname phantomsection\endcsname
    \listoffigures
    \addtocontents{lof}{\hrule height1pt\par\bigskip}
    \addcontentsline{toc}{section}{List of Figures}
    \clearpage
    \csname phantomsection\endcsname
    \listoftables
    \addtocontents{lot}{\hrule height1pt\par\bigskip}
    \addcontentsline{toc}{section}{List of Tables}
    \clearpage
}

\titleformat{\section}{\Large\bfseries}{\parbox{2cm}{\thesection}}{-0.5pt}{}
\titleformat{\subsection}{\large\bfseries}{\parbox{2cm}{\thesubsection}}{-0.5pt}{}
\titleformat{\subsubsection}{\normalsize\bfseries}{\parbox{2cm}{\thesubsubsection}}{-0.5pt}{}
\titlespacing*{\section}{-2cm}{0.6cm}{0.6cm}
\titlespacing*{\subsection}{-2cm}{0.4cm}{0.4cm}
\titlespacing*{\subsubsection}{-2cm}{0.2cm}{0.2cm}

\def\defineEasylist#1#2{\expandafter\def\csname 
    Easylist@style@#1\endcsname{\NewList(#2)}}
\def\Easylist{\futurelet\next\doEasylist}
\def\doEasylist{\ifx[\next\expandafter\doEasylistone\else\expandafter
    \doEasylistnop\fi}
\def\doEasylistone[#1] 
{\begin{easylist}\if\relax\detokenize{#1}\relax\else\csname 
        Easylist@style@#1\endcsname\fi}
    \def\doEasylistnop{\begin{easylist}\NewList}
        \def\endEasylist{\end{easylist}}

    \defineEasylist{lowercasestyle} 
    {Numbers=l,Hang=true,FinalSpace=0.2cm,Align=fixed, 
        Margin1=0.5cm,Margin2=1.5cm,Margin3=2.5cm,Margin4=3.5cm, 
        Margin5=4.5cm,Margin6=5.5cm,Margin7=6.5cm,Space=0.15cm,Space*=0.15cm}

    \defineEasylist{uppercasestyle} 
    {Numbers=L,Hang=true,FinalSpace=0.2cm,Align=fixed, 
        Margin1=0.5cm,Margin2=1.5cm,Margin3=2.5cm,Margin4=3.5cm, 
        Margin5=4.5cm,Margin6=5.5cm,Margin7=6.5cm,Space=0.15cm,Space*=0.15cm}

    \defineEasylist{romanlowercasestyle} 
    {Numbers=r,Hang=true,FinalSpace=0.2cm,Align=fixed, 
        Margin1=0.5cm,Margin2=1.5cm,Margin3=2.5cm,Margin4=3.5cm, 
        Margin5=4.5cm,Margin6=5.5cm,Margin7=6.5cm,Space=0.15cm,Space*=0.15cm}

    \defineEasylist{romanuppercasestyle} 
    {Numbers=R,Hang=true,FinalSpace=0.2cm,Align=fixed, 
        Margin1=0.5cm,Margin2=1.5cm,Margin3=2.5cm,Margin4=3.5cm, 
        Margin5=4.5cm,Margin6=5.5cm,Margin7=6.5cm,Space=0.15cm,Space*=0.15cm}

    \defineEasylist{bullet}{Hide=100,Hang=true,FinalSpace=0.5cm,Align=fixed, 
        Margin1=0.5cm,Margin2=1.5cm,Margin3=2.5cm,Margin4=3.5cm, 
        Margin5=4.5cm,Margin6=5.5cm,Margin7=6.5cm,Space=0.15cm,Space*=0.15cm,
        Style1*=\textbullet\hspace{0.25cm},Style2*=$\circ$\hspace{0.25cm},
        Style3*=$\star$\hspace{0.25cm},Style4*=$\mp$\hspace{0.25cm}}

\begin{document}
        \tocloflot
        \section{Section Section Section Section Section Section Section Section Section}
        \lipsum[1]

        \begin{Easylist}[bullet]
            & dog
            && cat
            &&& rabbit
        \end{Easylist}
        \par\bigskip
        \begin{Easylist}[lowercasestyle]
            & dog
            && cat
            &&& rabbit
        \end{Easylist}
        \par\bigskip
        \begin{Easylist}[romanuppercasestyle]
            & dog
            && cat
            &&& rabbit
        \end{Easylist}
        \par\bigskip
        \begin{Easylist}[romanlowercasestyle]
            & dog
            && cat
            &&& rabbit
        \end{Easylist}

        \subsection{Section Section Section Section Section Section Section Section Section Section Section Section Section Section Section Section Section Section}
        \lipsum[1]
        \subsubsection{Section Section Section Section Section Section Section Section Section Section Section Section Section Section Section Section Section Section}
        \lipsum[1]

\end{document}

在此处输入图片描述

答案1

adjustwidth以下是使用环境 fromchangepage\titlespacingfrom 的解决方案titlesec。后一个命令接受 3 个参数:第一个参数用于增加或减少左边距,另外两个参数用于标题前后的垂直间距。我将此命令合并到环境的最开始adjustwidth,以免干扰文档的常规设置。如果必须在文档中重复多次,您可以考虑在序言中使用 声明这些修改\AtBeginEnvironment{adjustwidth}{...}

\documentclass[a4paper,12pt]{article}
\usepackage{lipsum}

\usepackage[showframe]{geometry}
\geometry{paper=a4paper}
\geometry{bindingoffset=1.5cm,hmargin={1.5cm,1.5cm},vmargin={1cm,1cm}}
\geometry{includehead=true,headheight=3cm,headsep=1cm}
\geometry{includefoot=false}
\usepackage{changepage}
\usepackage{titlesec}

\begin{document}


\lipsum[11]
\begin{adjustwidth}{2cm}{}
\titleformat{\section}{\Large\bfseries}{\parbox{2cm}{\thesection}}{-0.5pt}{}
\titleformat{\subsection}{\large\bfseries}{\parbox{2cm}{\thesubsection}}{-0.5pt}{}
\titleformat{\subsubsection}{\normalsize\bfseries}{\parbox{2cm}{\thesubsubsection}}{-0.5pt}{}
\titlespacing{\section}{-2cm}{*3.5}{*2.}
\titlespacing{\subsection}{-2cm}{*3.25}{*1.5}
\titlespacing{\subsubsection}{-2cm}{*3.25}{*1.5}
\section{Section}
\lipsum[1]
\subsection{Subsection}
\lipsum[1]
\subsubsection{Subsubsection}
\lipsum[1]
\end{adjustwidth}

\end{document} 

在此处输入图片描述

编辑1

titlesec以下是在序言中使用修改后的代码:

\documentclass[a4paper,12pt]{article}
\usepackage{lipsum}

\usepackage[showframe]{geometry}
\geometry{paper=a4paper}
\geometry{bindingoffset=1.5cm,hmargin={1.5cm,1.5cm},vmargin={1cm,1cm}}
\geometry{includehead=true,headheight=3cm,headsep=1cm}
\geometry{includefoot=false}
\usepackage{changepage}
\usepackage{titlesec}
\usepackage{etoolbox} 
\AtBeginEnvironment{adjustwidth}{%
\titleformat{\section}{\Large\bfseries}{\parbox{2cm}{\thesection}}{-0.5pt}{}
\titleformat{\subsection}{\large\bfseries}{\parbox{2cm}{\thesubsection}}{-0.5pt}{}
\titleformat{\subsubsection}{\normalsize\bfseries}{\parbox{2cm}{\thesubsubsection}}{-0.5pt}{}
\titlespacing*{\section}{-2cm}{*3.5}{*2.}
\titlespacing*{\subsection}{-2cm}{*3.25}{*1.5}
\titlespacing*{\subsubsection}{-2cm}{*3.25}{*1.5}
}

\begin{document}

\lipsum[11]
\begin{adjustwidth}{2cm}{}
\section{Section}
\lipsum[1]
\subsection{Subsection}
\lipsum[1]
\subsubsection{Subsubsection}
\lipsum[1]
\end{adjustwidth}

\end{document}

编辑2

如果有适合多行的标题,并且希望它们距左边距 2 厘米,请将 的最后一个(空)参数替换为\titleformat\parbox如下所示:

\titleformat{\section}{\Large\bfseries}{\parbox[t]{2cm}{\thesection}}{-0.5pt}{\parbox[t]{\dimexpr\textwidth-2cm}}

对于子部分和子子部分同样如此。

在此处输入图片描述

相关内容