部分文本的边距调整

部分文本的边距调整

我一直在调整边距、部分尺寸、几何包尺寸和 titlesec 设置以获得此布局(但到目前为止失败了):(左边距设置为 0.75 英寸)

<-0.75in->HEADER LEFT                        HEADER RIGHT
<-0.75in->_______________________________________________

<-0.75in->1.    Section heading
          <-x->|
                Some text blah blah blah..................
                which is left-aligned with the section 
                heading.

我尝试过\titleformat将节号移到左侧,但这会使页眉左边距与正文对齐。我也尝试在我构建的自定义类中执行此操作。出于这个原因,我更愿意将节内文本的边距普遍更改为与节标题文本对齐,并允许更改页边距,而无需调整大量其他值。

希望您能理解。谢谢。

編輯:MWE

\documentclass[10pt, letterpaper, twoside]{article}
\usepackage[top=0.5in, bottom=0.5in, left=1.25in, right=0.75in]{geometry}
\usepackage{titlesec}
\usepackage{fancyhdr}
\usepackage{indentfirst}
\usepackage{lipsum}

\fancypagestyle{fancyHW}
{   
    \fancyhf{}
    \renewcommand{\headrulewidth}{1pt}
    \setlength{\headheight}{0.75in} 
    \setlength{\headsep}{12pt}
    \setlength{\footskip}{30pt}
    \setlength{\textheight}{670pt}
    \fancyhead[HL]{10/22/2014}
    \fancyhead[HC]{\footnotesize\textbf{My Title}}
    \fancyhead[HR]{Mr. Stumped}
    \fancyhead[RO]{\footnotesize \bf \thepage}
}

\fancypagestyle{fancyHWrest}
{
    \fancyhf{}
    \renewcommand{\headrulewidth}{1pt}
    \setlength{\headheight}{0.75in} 
    \setlength{\headsep}{12pt}
    \setlength{\textheight}{670pt}  
    \fancyhead[RE]{\footnotesize \it \nouppercase{\rightmark}}
    \fancyhead[LO]{\footnotesize \it \nouppercase{\rightmark}}
    \fancyhead[RO, LE]{\footnotesize \bf \thepage}
}

\pagestyle{fancyHWrest}
    \renewcommand{\sectionmark}[1]{ \markright{#1}{} }
\thispagestyle{fancyHW}

\setlength{\parindent}{0pt}

\titleformat{\section}[block]{\bfseries\large\hspace{-0.5in}}{\thesection.}{\leftmargin}{}

\begin{document}
\section{The First Section}
As you can see, the header is aligned with the text.  I am trying to get the header aligned with the section number while keeping the text aligned with the section title.

\lipsum

\section{The Next Section}
It also gets really messed up for two-sided documents, if the left and right margin are set to different values.  Moving only section text would alleviate this problem.
\end{document}

澄清:如果这让您感到困惑,我深表歉意。让我试着澄清一下我拥有什么,以及我想要实现什么。

-我拥有的:

我可以通过将节标签编号向左边距移动 -0.5 英寸并将节标签文本与 对齐,将节正文与节标签文本对齐\leftmargin。但是,这是一份双面文档。因此,如果我决定将“内”边距设为小于“外”边距(与 MWE 一样),则会出现一个问题:在奇数页上,节编号距离页面左侧 0.75 英寸,这没问题。但是,由于节编号向左边距偏移,在偶数页上,节编号距离页面左侧 0.25 英寸。

-我想要实现的目标:

将节号与 对齐\leftmargin,并将节标签文本和节正文文本与 对齐指定的距离\leftmargin。这样我就可以随意更改页边距geometry,而不会出现偶数页上页面左侧和节号之间的当前间距问题。

答案1

这是一个解决方案titleps。我定义了一个wideoddhead页面样式,它可以做你想做的事(如果我理解得没错的话),而不必更改边距。我不得不修改部分格式。还简化了你的序言:

\documentclass[10pt, letterpaper, twoside]{article}

\usepackage[vmargin=0.5in, left=1.25in, right=0.75in, headheight=0.75in, headsep=12pt, footskip=30pt, textheight=670pt]{geometry}
\usepackage[pagestyles, indentafter]{titlesec}

\newpagestyle{wideoddhead}{%
\setheadrule{1pt}
\widenhead[0pt][0pt]{0.5in}{0pt}
\sethead[\footnotesize\bfseries\thepage][][\footnotesize\itshape{\sectiontitle}]{10/22/2014}{\footnotesize\textbf{My Title}}{\footnotesize\bfseries\thepage}
}

\titleformat{\section}[block]{\bfseries\large}{\llap{\makebox[0.5in][l]{\thesection.}}}{0pt}{}
\pagestyle{wideoddhead}
\raggedbottom

\begin{document}

\section{The First Section}
Text text text text text text text text text text text text text text text text text text text text text text text text text.
As you can see, the header is aligned with the text. I am trying to get the header aligned with the section number while keeping the text aligned with the section title.
\pagebreak
\section{The Next Section}
It also gets really messed up for two-sided documents, if the left and right margin are set to different values. Moving only section text would alleviate this problem.

\end{document} 

在此处输入图片描述

在此处输入图片描述

答案2

章节编号位于左边距,因此它不会与标题对齐,除非您重新定义其中一个或两个。

我不确定您说“双面文档确实会变得一团糟”是什么意思。如果您不希望左右边距有不同的值,请将 linedocumentclass选项更改为oneside或使用以下命令重置左右边距:

\setlength\oddsidemargin{0in}
\setlength\evensidemargin{0in}

调整值以获得所需的边距宽度。

相关内容