1

I heavily use org-mode in Emacs to create TODO lists with timekeeping, which has a handy export to LaTeX feature. The problem is that in order to get my exported LaTeX document to look right, I want to indent entire sections, essentially treating sections like lists. It's very easy to create a template to copy and paste into every new file, but not feasible to edit the text directly as this would interfere with org-modes ease of use. Thus:

Is there a way to indent an entire section, using only the preamble?

MWE

\documentclass{article}
\usepackage[explicit]{titlesec}
\setcounter{secnumdepth}{0}
\newcommand{\clock}{CLOCK: number number number \\}

\titleformat{\section}{\bfseries{}}{\roman{section}}{3pt}{#1}
\titlespacing*{\section}{0pt}{0pt}{0pt}
\titleformat{\subsection}{\bfseries{}}{\roman{subsection}}{3pt}{$\rightarrow$#1}
\titlespacing*{\subsection}{2em}{0pt}{0pt}
\begin{document}


\section{First section}
\clock

\section{Second section}
\clock
\clock
\clock

\subsection{First subsection}
\clock
\clock

\subsection{Second subsection}
\clock

\subsection{Third subsection}
\clock

\end{document}

I want the text with the red arrow to be indented to the same level as the section. Minimum working example

  • Use \leftskip 3ex to create a global 3ex indent. Reset with \leftskip 0pt. – Steven B. Segletes Jan 14 '14 at 14:46
  • titlesec does something at the end of the heading which invalidates this; it indents the heading fine, just not the text afterwards. – Nathanael Farley Jan 14 '14 at 14:50
2

To be done in the preamble, all things of "that type" will be affected throughout the document. Based on your problem description, I interpreted it to mean that you would like all subsections to be indented.

\documentclass{article}
\usepackage[explicit]{titlesec}
\setcounter{secnumdepth}{0}
\newcommand{\clock}{CLOCK: number number number \\}

\titleformat{\section}{\bfseries{}}{\roman{section}}{3pt}{#1}
\titlespacing*{\section}{0pt}{0pt}{0pt}
\titleformat{\subsection}{\bfseries{}}{\roman{subsection}}{3pt}{$\rightarrow$#1}
\titlespacing*{\subsection}{2em}{0pt}{0pt}

\let\svsection\section
\let\svsubsection\subsection
\def\section{\leftskip 0ex\svsection}
\def\subsection{\leftskip 4.5ex\svsubsection}
\begin{document}


\section{First section}
\clock

\section{Second section}
\clock
\clock
\clock

\subsection{First subsection}
\clock
\clock

\subsection{Second subsection}
\clock

\subsection{Third subsection}
\clock

\section{Third Section}
\clock

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.