
Tengo un documento de 60 páginas con Secciones, subsecciones y párrafos numerados. Todos los párrafos están numerados. Quiero que todo el texto tenga una sangría uniforme después de los párrafos numerados, como se muestra en el siguiente ejemplo:
1. Section
1.1 Subsection
1.1.1 Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Donec rhoncus non ante faucibus tempus. Quisque ex orci,
faucibus vitae magna sed, blandit fermentum massa.
1.1.2 Some numbered paras interrupted by lists:
* Item 1
* Item 2
* Item 3
and some text to finish the paragraph
1.1.2 Some numbered paras interrupted by sets of equations using AMSmath:
A = B
C = D
and some text to finish the paragraph
Actualmente, tengo unas 60 páginas de texto (incluidas muchas ecuaciones), creadas en torno a la siguiente clase de koma-script:
% -*- program: xelatex -*-
\documentclass[english, parskip=full, fontsize=11, DIV12, toc=left, numbers=noenddot]{scrartcl}
\usepackage{babel}
\usepackage{amsmath}
% just so we can see what is going on for now
\usepackage{showframe}
\usepackage{blindtext}
% tighten up spacing of lists
\usepackage{enumitem}
\setlist{noitemsep}
\setcounter{secnumdepth}{4}
\renewcommand\theparagraph{\thesubsection.\arabic{paragraph}}
\newcommand\p{\paragraph{}}
%
%
% make sure paragraphs reset counting at section and subsections
%
\makeatletter
\@addtoreset{paragraph}{subsection}
\@addtoreset{paragraph}{section}
\makeatother
%
% AND NOW WE BEGIN
%
\begin{document}
\section{Section}
\subsection {Subsection}
\p \blindtext
% an example numbered paragraph with an embedded list
\p \blindtext
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
and some words at the end of this para
% an example numbered paragraph with a simple equation
\p The period is defined by a pair of days ($D_l$, $D_u$) where
\begin{align*}
D^_{l} & = \text{the lower date} \\
D^_{u} & = \text{the upper date}
\end{align*}
and things happen for all days $d$ where $D_l <= d< D_u$.
\end{document}
entonces, todo el texto vuelve al margen izquierdo. Sería ideal si pudiera usar algo como el \addmargin
comando koma-script para sangrar listas y matemáticas desde la izquierda; pero ajuste el \p
comando de párrafo numerado para que su numeración comience alineada a la izquierda, pero con un cuadro alrededor del número para darle un tamaño estándar, y luego un comando colgante para el resto del \p para igualarlo con el resto del texto sangrado.
O algo mas ....
Pero hasta ahora, esto está más allá de mis habilidades en LaTeX.
Respuesta1
Actualizar:Script KOMAversión 3.17 (o más reciente)
Con la versión KOMA-Script el comando \othersectionlevelsformat
está depreciado. Tienes que usar en su lugar \sectionformat
, \subsectionformat
etc. Entonces el código cambia a
% -*- program: xelatex -*-
\documentclass[english, parskip=full, fontsize=11, DIV12, toc=left, numbers=noenddot]{scrartcl}
\usepackage{babel}
\usepackage{amsmath}
% just so we can see what is going on for now
\usepackage{showframe}
\usepackage{blindtext}
% tighten up spacing of lists
\usepackage{enumitem}
\setlist{noitemsep}
\setcounter{secnumdepth}{4}
\newcommand\p{\paragraph{}}
\newcommand\secnumindent{1.5cm}
\RedeclareSectionCommands[indent=-\secnumindent]{section,subsection,paragraph}
\RedeclareSectionCommand[afterskip=0pt,counterwithin=subsection]{paragraph}
\renewcommand\sectionformat{\parbox{\secnumindent}{\thesection\autodot}}
\renewcommand\subsectionformat{\parbox{\secnumindent}{\thesubsection\autodot}}
\renewcommand\subsubsectionformat{\parbox{\secnumindent}{\thesubsubsection\autodot}}
\renewcommand\paragraphformat{\parbox{\secnumindent}{\theparagraph\autodot}}
% from the answer of @Steven:
\addtolength\hoffset{\secnumindent}
\addtolength\textwidth{-\secnumindent}
%
% make sure paragraphs reset counting also at sections
%
\makeatletter
\@addtoreset{paragraph}{section}
\makeatother
% to reset headwidth and footwidth
\usepackage[
headwidth=\the\textwidth+\secnumindent:-\secnumindent,
footwidth=head:-\secnumindent,
headsepline,% to show the headwidth
footsepline% to show the footwidth
]{scrlayer-scrpage}
%
% AND NOW WE BEGIN
%
\begin{document}
\section{Section}
\subsection {Subsection}\label{sec:first}
\p \blindtext
% a reference
\p See \ref{sec:first}
% an example numbered paragraph with an embedded list
\p \blindtext
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
and some words at the end of this para
% an example numbered paragraph with a simple equation
\p The period is defined by a pair of days ($D_l$, $D_u$) where
\begin{align*}
D_{l} & = \text{the lower date} \\
D_{u} & = \text{the upper date}
\end{align*}
and things happen for all days $d$ where $D_l <= d< D_u$.
\section{Next section}
\subsection{Next subsection}
\p \blindtext
\end{document}
El resultado es el mismo que en la imagen de abajo.
Si esto también debería ser compilable con las versiones 3.15 y 3.16, inserte
\renewcommand\othersectionlevelsformat[3]{\parbox{\secnumindent}{#3\autodot}}
\providecommand\sectionformat{}\providecommand\subsectionformat{}
\providecommand\subsubsectionformat{}\providecommand\paragraphformat{}
justo antes de redefinir \sectionformat
, etc.
Script KOMAversión 3.15 y 3.16
Puede utilizar los nuevos comandos \RedeclareSectionCommand
o \RedeclareSectionCommands
y redefinir \othersectionlevelsformat
. Por lo tanto, todavía es posible hacer referencia a un número de sección mediante \ref
:
\setcounter{secnumdepth}{4}
\newcommand\p{\paragraph{}}
\newcommand\secnumindent{1.5cm}
\RedeclareSectionCommands[indent=-\secnumindent]{section,subsection,paragraph}
\RedeclareSectionCommand[afterskip=0pt,counterwithin=subsection]{paragraph}
\renewcommand\othersectionlevelsformat[3]{\parbox{\secnumindent}{#3\autodot}}
% from the answer of @Steven:
\addtolength\hoffset{\secnumindent}
\addtolength\textwidth{-\secnumindent}
%
% make sure paragraphs reset counting also at sections
%
\makeatletter
\@addtoreset{paragraph}{section}
\makeatother
Para restablecer el ancho de cabeza y de pie originales, puede utilizar
\usepackage[
headwidth=\the\textwidth+\secnumindent:-\secnumindent,
footwidth=head:-\secnumindent,
headsepline,% to show the headwidth
footsepline% to show the footwidth
]{scrlayer-scrpage}
Código:
% -*- program: xelatex -*-
\documentclass[english, parskip=full, fontsize=11, DIV12, toc=left, numbers=noenddot]{scrartcl}
\usepackage{babel}
\usepackage{amsmath}
% just so we can see what is going on for now
\usepackage{showframe}
\usepackage{blindtext}
% tighten up spacing of lists
\usepackage{enumitem}
\setlist{noitemsep}
\setcounter{secnumdepth}{4}
\newcommand\p{\paragraph{}}
\newcommand\secnumindent{1.5cm}
\RedeclareSectionCommands[indent=-\secnumindent]{section,subsection,paragraph}
\RedeclareSectionCommand[afterskip=0pt,counterwithin=subsection]{paragraph}
\renewcommand\othersectionlevelsformat[3]{\parbox{\secnumindent}{#3\autodot}}
% from the answer of @Steven:
\addtolength\hoffset{\secnumindent}
\addtolength\textwidth{-\secnumindent}
%
% make sure paragraphs reset counting also at sections
%
\makeatletter
\@addtoreset{paragraph}{section}
\makeatother
% to reset headwidth and footwidth
\usepackage[
headwidth=\the\textwidth+\secnumindent:-\secnumindent,
footwidth=head:-\secnumindent,
headsepline,% to show the headwidth
footsepline% to show the footwidth
]{scrlayer-scrpage}
%
% AND NOW WE BEGIN
%
\begin{document}
\section{Section}
\subsection {Subsection}\label{sec:first}
\p \blindtext
% a reference
\p See \ref{sec:first}
% an example numbered paragraph with an embedded list
\p \blindtext
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
and some words at the end of this para
% an example numbered paragraph with a simple equation
\p The period is defined by a pair of days ($D_l$, $D_u$) where
\begin{align*}
D_{l} & = \text{the lower date} \\
D_{u} & = \text{the upper date}
\end{align*}
and things happen for all days $d$ where $D_l <= d< D_u$.
\section{Next section}
\subsection{Next subsection}
\p \blindtext
\end{document}
KOMA-Script versión 3.14 (o anterior)
Aquí hay otra sugerencia que utiliza la respuesta de @Steven pero redefiniendo \othersectionlevelsformat
en lugar de \thesection
. Por lo tanto, todavía es posible hacer referencia a un número de sección mediante \ref
:
\newcommand\p{\paragraph{}\hspace*{-1em}}
\newcommand\secnumindent{1.5cm}
\renewcommand\othersectionlevelsformat[3]{\makebox[0pt][r]{\parbox{\secnumindent}{#3\autodot}}}
% from the answer of @Steven:
\addtolength\hoffset{\secnumindent}
\addtolength\textwidth{-\secnumindent}
Código:
% -*- program: xelatex -*-
\documentclass[english, parskip=full, fontsize=11, DIV12, toc=left, numbers=noenddot]{scrartcl}
\usepackage{babel}
\usepackage{amsmath}
% just so we can see what is going on for now
\usepackage{showframe}
\usepackage{blindtext}
% tighten up spacing of lists
\usepackage{enumitem}
\setlist{noitemsep}
\setcounter{secnumdepth}{4}
\renewcommand\theparagraph{\thesubsection.\arabic{paragraph}}
\newcommand\p{\paragraph{}\hspace*{-1em}}
\newcommand\secnumindent{1.5cm}
\renewcommand\othersectionlevelsformat[3]{\makebox[0pt][r]{\parbox{\secnumindent}{#3\autodot}}}
% from the answer of @Steven:
\addtolength\hoffset{\secnumindent}
\addtolength\textwidth{-\secnumindent}
% to reset headwidth and footwidth
\usepackage[
headwidth=\the\textwidth+\secnumindent:-\secnumindent,
footwidth=head:-\secnumindent,
headsepline,% to show the headwidth
footsepline% to show the footwidth
]{scrlayer-scrpage}
%
% make sure paragraphs reset counting at section and subsections
%
\makeatletter
\@addtoreset{paragraph}{subsection}
\@addtoreset{paragraph}{section}
\makeatother
%
% AND NOW WE BEGIN
%
\begin{document}
\section{Section}
\subsection {Subsection}\label{sec:first}
\p \blindtext
% a reference
\p See \ref{sec:first}
% an example numbered paragraph with an embedded list
\p \blindtext
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
and some words at the end of this para
% an example numbered paragraph with a simple equation
\p The period is defined by a pair of days ($D_l$, $D_u$) where
\begin{align*}
D_{l} & = \text{the lower date} \\
D_{u} & = \text{the upper date}
\end{align*}
and things happen for all days $d$ where $D_l <= d< D_u$.
\section{Next section}
\subsection{Next subsection}
\p \blindtext
\end{document}
Respuesta2
Como sugerí [aproximadamente] en el comentario, agregue estas líneas al preámbulo
\let\svthesection\thesection
\def\thesection{\kern-1.5cm\svthesection}
\hoffset=\dimexpr\hoffset + 1.5cm\relax
\textwidth=\dimexpr\textwidth-1.5cm\relax
\paperwidth=\dimexpr\paperwidth -1.5cm\relax
Lo que logran es: 1) guardar una copia de \thesection
; 2) redefinir \thesection
el interletraje 1,5 cm a la izquierda antes de imprimir el encabezado de la sección; 3) modificar \hoffset
para desplazar todo el documento 1,5 cm hacia la derecha; 4) reducir el \textwidth
en 1,5 cm (combinado con el \hoffset
, deja el margen derecho sin cambios); y 5) reduce el ancho del papel en 1,5 cm, para tener en cuenta la \hoffset
modificación.
Indiqué que este enfoque tenía desventajas asociadas, que se pueden observar en las figuras debajo del MWE. El encabezado y pie de página están desplazados, lo que significa que los números de página centrados ahora están desplazados 0,75 cm hacia la derecha, en comparación con el código original del OP.
El OP indicó que este enfoque funcionó para sus necesidades y solo requirió la adición de un \begin{addmargin}
entorno. Como no estoy exactamente seguro de dónde pudo haber colocado el OP ese código adicional, no intenté insertarlo en mi MWE.
Tenga en cuenta que ^
se eliminaron las marcas de superíndice perdidas del código del OP en el align*
entorno (una eliminada por línea) para facilitar la compilación. Este código fue compilado en XeLaTeX, aunque también se compila en pdflatex.
% -*- program: xelatex -*-
\documentclass[english, parskip=full, fontsize=11, DIV12, toc=left, numbers=noenddot]{scrartcl}
\usepackage{babel}
\usepackage{amsmath}
% just so we can see what is going on for now
\usepackage{showframe}
\usepackage{blindtext}
% tighten up spacing of lists
\usepackage{enumitem}
\setlist{noitemsep}
\setcounter{secnumdepth}{4}
\renewcommand\theparagraph{\thesubsection.\arabic{paragraph}}
\newcommand\p{\paragraph{}}
%
%
% make sure paragraphs reset counting at section and subsections
%
\makeatletter
\@addtoreset{paragraph}{subsection}
\@addtoreset{paragraph}{section}
\makeatother
\let\svthesection\thesection
\def\thesection{\kern-1.5cm\svthesection}
\hoffset=\dimexpr\hoffset + 1.5cm\relax
\textwidth=\dimexpr\textwidth-1.5cm\relax
\paperwidth=\dimexpr\paperwidth -1.5cm\relax
%
% AND NOW WE BEGIN
%
\begin{document}
\section{Section}
\subsection {Subsection}
\p \blindtext
% an example numbered paragraph with an embedded list
\p \blindtext
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
and some words at the end of this para
% an example numbered paragraph with a simple equation
\p The period is defined by a pair of days ($D_l$, $D_u$) where
\begin{align*}
D_{l} & = \text{the lower date} \\
D_{u} & = \text{the upper date}
\end{align*}
and things happen for all days $d$ where $D_l <= d< D_u$.
\end{document}
RESULTADO ORIGINAL DEL OP
CON MI CAMBIO SUGERIDO