嗨,这个问题是跟进有关 \leftskip 的问题让我重新考虑我的乳胶使用情况。David Carlisle 说我对 leftskip 的使用是错误的,我想纠正这一点......
以下是我的文档的 mwe,它实际上被分成了不同的文件,但现在这不重要了。我需要的是关于如何清理文件以便更顺利地工作的建议。
\documentclass{article}
\usepackage[
left={\dimexpr 10mm + 55pt},
right=20mm,
top=20mm,
bottom=18mm,
footskip=2em,
headheight=2em,
headsep=0.8em,
showframe
]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy} % --- new header
\renewcommand{\headrulewidth}{0.1pt}
\renewcommand{\footrulewidth}{0.1pt}
\setlength{\headheight}{16pt} % --- new header end
\usepackage{tocloft} %is alpha but it solves the indent on sectons
\tocloftpagestyle{empty}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
\makeatletter %---------- start of @ sequencecontrollers ----------
\renewcommand{\@tocrmarg}{15mm} %right margin
\renewcommand{\@pnumwidth} {10mm}
\renewcommand{\@dotsep}{4}
\makeatother %---------- end of @ sequencecontrollers ----------
\renewcommand{\cftaftertoctitle}{\\[\baselineskip]\mbox{}\hfill{\footnotesize\scshape Seite}} %sets the word "page" upon the pagenumbers
\setlength{\parskip}{0pt}
\setlength{\parindent}{0pt}
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\fontsize{17pt}{18pt}
\selectfont\scshape}{\rlap{\thesection}}{55pt}{}
\titlespacing{\section}{-55pt}{3.5ex plus 1ex minus .2ex}%
{2.3ex plus.2ex}%
\titleformat{\subsection}
{\normalfont\fontsize{16pt}{17pt}
\selectfont\scshape}{\rlap{\thesubsection}}{55pt}{}
\titlespacing{\subsection}{-55pt}{3.25ex plus 1ex minus .2ex}%
{1.5ex plus .2ex}%
\titleformat{\subsubsection}
{\normalfont\fontsize{15pt}{16pt}
\selectfont\scshape}{\rlap{\thesubsubsection}}{55pt}{}
\titlespacing{\subsubsection}{-55pt}{3.25ex plus 1ex minus .2ex}%
{1.5ex plus .2ex}%
\titleformat{\paragraph}
{\normalfont\fontsize{14pt}{15pt}
\selectfont\scshape}{\rlap{\theparagraph}}{55pt}{}
\titlespacing{\paragraph}{-55pt}{3.25ex plus 1ex minus .2ex}%
{1em}%
\titleformat{\subparagraph}
{\normalfont\fontsize{13pt}{14pt}
\selectfont\scshape}{\rlap{\thesubparagraph}}{55pt}{}
\titlespacing{\subparagraph}{-55pt}{3.25ex plus 1ex minus .2ex}%
{1em}%
\setcounter{secnumdepth}{5}
\begin{document}
\newgeometry{ % ------------- reset for centering -------------
left=15mm,
right=20mm,
top=20mm,
bottom=18mm,
footskip=2em,
headheight=2em,
headsep=0.8em
}
\tableofcontents
\thispagestyle{empty}
\clearpage
\restoregeometry % ------------- back to document setting (left+55pt) -------------
\setcounter{page}{1}
\section{One}
\lipsum[1]
\subsection{SubOne}
\lipsum[2]
\begin{figure}[!ht]
\begin{flushright}
\includegraphics[width=\linewidth]{example-image}
\end{flushright}
\end{figure}
\section{two}
\lipsum[3]
\subsection{SubTwo}
\begin{figure}[!ht]
\begin{flushright}
\includegraphics[width=\textwidth]{example-image}
\end{flushright}
\end{figure}
\lipsum[4]
\subsubsection{SubSubOne}
\lipsum[5]
\paragraph{ParOne}
\lipsum[6]
\subparagraph{SubParOne}
\lipsum[7]
\end{document}
David 说“加载几何图形以一致的方式设置页面大小和边距,然后手动更改诸如 \textwidth 之类的设置,这没有多大意义,只需使用geometry
“
我怎样才能制作像 MWE 中那样的页面而不手动设置这些值?
编辑:在 John Kormylo 的帮助下,leftskip 问题已得到解决(非常感谢!)现在只有 Header 需要再次超出整个宽度...
让我在这里添加 John Kormylo 的精彩解决方案,并就新样本 MWE 提出两个新问题:
\documentclass{article}
\usepackage[
left=20mm,
right=20mm,
top=20mm,
bottom=18mm,
footskip=2em,
headheight=2em,
headsep=0.8em
]{geometry}
\usepackage{filecontents} %----------- i am adding a bibliography file -----------
\begin{filecontents*}{main.bib}
@Book{Goossens,
author = {Goossens, Michel and Mittelbach, Frank and
Samarin, Alexander},
title = {The LaTeX Companion},
edition = {1},
publisher = {Addison-Wesley},
location = {Reading, Mass.},
year = {1994},
}
@Book{adams,
title = {The Restaurant at the End of the Universe},
author = {Douglas Adams},
series = {The Hitchhiker's Guide to the Galaxy},
publisher = {Pan Macmillan},
year = {1980},
}
\end{filecontents*}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{paracol}
\setlength{\columnsep}{0pt}
\setcolumnwidth{55pt,{\dimexpr \textwidth-55pt}}
\usepackage{fancyhdr}
\pagestyle{fancy} % --- new header
\renewcommand{\headrulewidth}{0.1pt}
\renewcommand{\footrulewidth}{0.1pt}
\setlength{\headheight}{16pt} % --- new header end
\usepackage{tocloft} %is alpha but it solves the indent on sectons
\tocloftpagestyle{empty}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
\makeatletter %---------- start of @ sequencecontrollers ----------
\renewcommand{\@tocrmarg}{15mm} %right margin
\renewcommand{\@pnumwidth} {10mm}
\renewcommand{\@dotsep}{4}
\makeatother %---------- end of @ sequencecontrollers ----------
\renewcommand{\cftaftertoctitle}{\\[\baselineskip]\mbox{}\hfill{\footnotesize\scshape Seite}} %sets the word "page" upon the pagenumbers
\setlength{\parskip}{0pt}
\setlength{\parindent}{0pt}
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\fontsize{17pt}{18pt}
\selectfont\scshape}{\rlap{\thesection}}{55pt}{}
\titlespacing{\section}{-55pt}{3.5ex plus 1ex minus .2ex}%
{2.3ex plus.2ex}%
\titleformat{\subsection}
{\normalfont\fontsize{16pt}{17pt}
\selectfont\scshape}{\rlap{\thesubsection}}{55pt}{}
\titlespacing{\subsection}{-55pt}{3.25ex plus 1ex minus .2ex}%
{1.5ex plus .2ex}%
\titleformat{\subsubsection}
{\normalfont\fontsize{15pt}{16pt}
\selectfont\scshape}{\rlap{\thesubsubsection}}{55pt}{}
\titlespacing{\subsubsection}{-55pt}{3.25ex plus 1ex minus .2ex}%
{1.5ex plus .2ex}%
\titleformat{\paragraph}
{\normalfont\fontsize{14pt}{15pt}
\selectfont\scshape}{\rlap{\theparagraph}}{55pt}{}
\titlespacing{\paragraph}{-55pt}{3.25ex plus 1ex minus .2ex}%
{1em}%
\titleformat{\subparagraph}
{\normalfont\fontsize{13pt}{14pt}
\selectfont\scshape}{\rlap{\thesubparagraph}}{55pt}{}
\titlespacing{\subparagraph}{-55pt}{3.25ex plus 1ex minus .2ex}%
{1em}%
\setcounter{secnumdepth}{5}
%----------- i am adding a bibliography here -----------
\usepackage[backend=bibtex, style=numeric, defernumbers]{biblatex}
\DeclareBibliographyCategory{skipbibliography}
\DeclareCiteCommand{\cite}[\mkbibfootnote]
{\usebibmacro{prenote}}
{\addtocategory{skipbibliography}{\thefield{entrykey}}%
\usedriver
{\DeclareNameAlias{sortname}{default}}
{\thefield{entrytype}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\usepackage{csquotes}
\appto{\bibsetup}{\emergencystretch=1em}
\addbibresource{main.bib}
%----------- i am adding a index here-----------
\usepackage{imakeidx}
\makeindex[
columns=3,
title=Alphabetischer Index,
options= -s latexfiles/style-index.tex]
%----------- i am adding a glosssary here -----------
\usepackage{glossaries}
\makeglossaries
\newglossaryentry{latex}
{
name=latex,
description={Is a mark up language specially suited
for scientific documents}
}
\newglossaryentry{maths}
{
name=mathematics,
description={Mathematics is what mathematicians do}
}
\begin{document} %----------- the document starts -----------
\tableofcontents
\thispagestyle{empty}
\clearpage
\setcounter{page}{1}
\begin{paracol}{2}
\switchcolumn
\section{One}
\lipsum[1]
\subsection{SubOne}
\lipsum[2]
\cite{adams} %----------- bib -----------
\index{keyword} %----------- index -----------
\Gls{latex} %----------- glosssary-----------
\begin{figure}[!ht]
\includegraphics[width=\linewidth]{example-image}
\caption{Image SubOne}
\end{figure}
\section{two}
\lipsum[3]
\subsection{SubTwo}
\begin{figure}[!ht]
\includegraphics[width=\linewidth]{example-image}
\caption{Image SubTwo}
\end{figure}
\lipsum[4]
\cite{Goossens} %----------- bib -----------
\index{key} %----------- index -----------
\gls{maths} %----------- glosssary-----------
\subsubsection{SubSubOne}
\lipsum[5]
\begin{table}[htp]
\centering
\begin{tabular}{|l|p{9cm}|l|l|}\hline
Nr & desc & kriteria & priority \\ \hline
1 & A1 & T1 & M \\ \hline
2 & A2 & F2 & K1 \\ \hline
3 & A3 & T1 & M \\ \hline
\multicolumn{4}{l}{* Legend: M = must, K1 = high, K2 = mid, K3 = low}
\end{tabular}
\caption{Targets}
\end{table}
\paragraph{ParOne}
\lipsum[6]
\subparagraph{SubParOne}
\lipsum[7]
\newpage
\section{References} %----------- the document starts -----------
\switchcolumn*
\begin{column}
\printbibliography%------------------ BIBLIOGRAPHY --------------------------------
\listoffigures%------------------------- FIGURES ------------------------------------
\listoftables%-------------------------- TABLES --------------------------------------
\printindex%--------------------------- INDEX --------------------------------------
\printglossaries%--------------------- GLOSSARY -----------------------------------
\end{column}
\end{paracol}
\end{document}
答案1
这是一种不使用 即可实现相同效果的方法\leftskip
。我尝试从 article 类中获取默认垂直间距,但对负值的使用感到困惑。(如果不使用 titlesec,这会容易得多!)
\documentclass{article}
\usepackage[
left={\dimexpr 20mm + 55pt},
right=20mm,
top=20mm,
bottom=18mm,
footskip=2em,
headheight=2em,
headsep=0.8em,
showframe
]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{lipsum}
%\leftskip=55pt
\setlength{\parskip}{\baselineskip}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt}
%\setlength{\textwidth}{483pt}
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\fontsize{17pt}{18pt}
\selectfont\scshape}{\rlap{\thesection}}{55pt}{}
\titlespacing{\section}{-55pt}{3.5ex plus 1ex minus .2ex}%
{2.3ex plus.2ex}%
\titleformat{\subsection}
{\normalfont\fontsize{16pt}{17pt}
\selectfont\scshape}{\rlap{\thesubsection}}{55pt}{}
\titlespacing{\subsection}{-55pt}{3.25ex plus 1ex minus .2ex}%
{1.5ex plus .2ex}%
\titleformat{\subsubsection}
{\normalfont\fontsize{15pt}{16pt}
\selectfont\scshape}{\rlap{\thesubsubsection}}{55pt}{}
\titlespacing{\subsubsection}{-55pt}{3.25ex plus 1ex minus .2ex}%
{1.5ex plus .2ex}%
\titleformat{\paragraph}
{\normalfont\fontsize{14pt}{15pt}
\selectfont\scshape}{\rlap{\theparagraph}}{55pt}{}
\titlespacing{\paragraph}{-55pt}{3.25ex plus 1ex minus .2ex}%
{1em}%
\titleformat{\subparagraph}
{\normalfont\fontsize{13pt}{14pt}
\selectfont\scshape}{\rlap{\thesubparagraph}}{55pt}{}
\titlespacing{\subparagraph}{-55pt}{3.25ex plus 1ex minus .2ex}%
{1em}%
\setcounter{secnumdepth}{5}
\begin{document}
\section{One}
\lipsum[1]
\subsection{SubOne}
\lipsum[2]
\begin{figure}[!ht]
\includegraphics[width=\textwidth]{example-image}
\end{figure}
\section{two}
\lipsum[3]
\subsection{SubTwo}
\begin{figure}[!ht]
\includegraphics[width=\textwidth]{example-image}
\end{figure}
\lipsum[4]
\subsubsection{SubSubOne}
\lipsum[5]
\paragraph{ParOne}
\lipsum[6]
\subparagraph{SubParOne}
\lipsum[7]
\end{document}
这是不使用 titlesec 的版本。它可能看起来不太简单,但我所要做的就是复制和粘贴。
我还必须进行更改\@seccntformat
以创建恒定的 55pt 宽度部分编号。
\documentclass{article}
\usepackage[
left={\dimexpr 20mm + 55pt},
right=20mm,
top=20mm,
bottom=18mm,
footskip=2em,
headheight=2em,
headsep=0.8em,
showframe
]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{lipsum}
%\setlength{\parskip}{\baselineskip}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt}
\makeatletter
\renewcommand\section{\@startsection {section}{1}{-55pt}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\fontsize{17pt}{18pt}\selectfont\scshape}}
\renewcommand\subsection{\@startsection{subsection}{2}{-55pt}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\fontsize{16pt}{17pt}\selectfont\scshape}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{-55pt}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\fontsize{15pt}{16pt}\selectfont\scshape}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{-55pt}%
{3.25ex \@plus1ex \@minus.2ex}%
{-1em}%
{\normalfont\fontsize{14pt}{15pt}\selectfont\scshape}}
\renewcommand\subparagraph{\@startsection{subparagraph}{5}{-55pt}%
{3.25ex \@plus1ex \@minus .2ex}%
{-1em}%
{\normalfont\fontsize{13pt}{14pt}\selectfont\scshape}}
\def\@seccntformat#1{\hbox to 55pt{\csname the#1\endcsname\hfil}}
\makeatother
\setcounter{secnumdepth}{5}
\begin{document}
\section{One}
\lipsum[1]
\subsection{SubOne}
\lipsum[2]
\begin{figure}[!ht]
\includegraphics[width=\textwidth]{example-image}
\end{figure}
\section{two}
\lipsum[3]
\subsection{SubTwo}
\begin{figure}[!ht]
\includegraphics[width=\textwidth]{example-image}
\end{figure}
\lipsum[4]
\subsubsection{SubSubOne}
\lipsum[5]
\paragraph{ParOne}
\lipsum[6]
\subparagraph{SubParOne}
\lipsum[7]
\end{document}
在这个解决方案中(基于修改后的问题),我使用 paracol 仅使用右列来减少宽度。 \textwidth
指的是整个页面,而\columnwidth
和\linewidth
可用于减少的空间。
\documentclass{article}
\usepackage[
left=20mm,
right=20mm,
top=20mm,
bottom=18mm,
footskip=2em,
headheight=2em,
headsep=0.8em
]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{paracol}
\setlength{\columnsep}{0pt}
\setcolumnwidth{55pt,{\dimexpr \textwidth-55pt}}
\usepackage{fancyhdr}
\pagestyle{fancy} % --- new header
\renewcommand{\headrulewidth}{0.1pt}
\renewcommand{\footrulewidth}{0.1pt}
\setlength{\headheight}{16pt} % --- new header end
\usepackage{tocloft} %is alpha but it solves the indent on sectons
\tocloftpagestyle{empty}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
\makeatletter %---------- start of @ sequencecontrollers ----------
\renewcommand{\@tocrmarg}{15mm} %right margin
\renewcommand{\@pnumwidth} {10mm}
\renewcommand{\@dotsep}{4}
\makeatother %---------- end of @ sequencecontrollers ----------
\renewcommand{\cftaftertoctitle}{\\[\baselineskip]\mbox{}\hfill{\footnotesize\scshape Seite}} %sets the word "page" upon the pagenumbers
\setlength{\parskip}{0pt}
\setlength{\parindent}{0pt}
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\fontsize{17pt}{18pt}
\selectfont\scshape}{\rlap{\thesection}}{55pt}{}
\titlespacing{\section}{-55pt}{3.5ex plus 1ex minus .2ex}%
{2.3ex plus.2ex}%
\titleformat{\subsection}
{\normalfont\fontsize{16pt}{17pt}
\selectfont\scshape}{\rlap{\thesubsection}}{55pt}{}
\titlespacing{\subsection}{-55pt}{3.25ex plus 1ex minus .2ex}%
{1.5ex plus .2ex}%
\titleformat{\subsubsection}
{\normalfont\fontsize{15pt}{16pt}
\selectfont\scshape}{\rlap{\thesubsubsection}}{55pt}{}
\titlespacing{\subsubsection}{-55pt}{3.25ex plus 1ex minus .2ex}%
{1.5ex plus .2ex}%
\titleformat{\paragraph}
{\normalfont\fontsize{14pt}{15pt}
\selectfont\scshape}{\rlap{\theparagraph}}{55pt}{}
\titlespacing{\paragraph}{-55pt}{3.25ex plus 1ex minus .2ex}%
{1em}%
\titleformat{\subparagraph}
{\normalfont\fontsize{13pt}{14pt}
\selectfont\scshape}{\rlap{\thesubparagraph}}{55pt}{}
\titlespacing{\subparagraph}{-55pt}{3.25ex plus 1ex minus .2ex}%
{1em}%
\setcounter{secnumdepth}{5}
\begin{document}
\tableofcontents
\thispagestyle{empty}
\clearpage
\setcounter{page}{1}
\begin{paracol}{2}
\switchcolumn
\section{One}
\lipsum[1]
\subsection{SubOne}
\lipsum[2]
\begin{figure}[!ht]
\includegraphics[width=\linewidth]{example-image}
\end{figure}
\section{two}
\lipsum[3]
\subsection{SubTwo}
\begin{figure}[!ht]
\includegraphics[width=\linewidth]{example-image}
\end{figure}
\lipsum[4]
\subsubsection{SubSubOne}
\lipsum[5]
\paragraph{ParOne}
\lipsum[6]
\subparagraph{SubParOne}
\lipsum[7]
\end{paracol}
\end{document}