2

It might be a simple yet a silly question but it keeps bugging me for days. Base on my code:

\documentclass[a4paper, 11pt]{article} 
\usepackage[margin=2cm]{geometry} % changes the margin
\usepackage{enumitem}
\usepackage{titlesec}
\usepackage{indentfirst}
\usepackage{blindtext}

\renewcommand\thesection{\Alph{section}.}
\renewcommand\thesubsection{\arabic{subsection}.}
\titleformat{\section}
{\normalfont\fontsize{11}{.5em}\bfseries}{\thesection}{.5em}
    {}
\titleformat{\subsection}
{\normalfont\fontsize{11}{.5em}\selectfont}{\thesubsection}{.5em}
    {}
\titlespacing % starred version: first paragraph is not indented
{\subsection} % <command>
{1em} % <left>
{.4em} % <before-sep>
{.3em} % <after-sep>

\begin{document}

\section{Introduction}
\subsection{Subsection One}
    \begin{itemize}  [leftmargin=1.3cm,topsep=0pt,itemsep=0pt,parsep=0pt,partopsep=0pt]
        \item some item here and there
        \item some item here and there
    \end{itemize}

\subsection{Subsection Two}
\setlength\parindent{.85cm} \blindtext

\end{document}

And it resulted in this picture Output Result

My question is, how can I adjust the paragraph margin parallel with the subsection number? and not the section number?

  • 1
    Welcome! What exactly should be aligned with what? Note that you really do NOT want to use dimensions with no stretch in your heading definitions for vertical spaces, as this will reduce TeX's ability to find good places to break pages. – cfr Feb 19 '18 at 3:03
  • Put it simple, my intention was to create left margin on the second subsection paragraph so it will inline with the subsection numbering, instead of section numbering – Bram Setyadji Madusuyatno Feb 19 '18 at 3:29
  • paragraphs left border is correct, but you should redefine \section{...} style that it can protrude into left margin. solutions for this you can find on the site. try to change question tag to section and styles. – Zarko Feb 19 '18 at 4:28
  • @Zarko sadly as a newbie I do not have enough "reputation" to put {section} and {styles} in tag (it requires +300) – Bram Setyadji Madusuyatno Feb 19 '18 at 5:20
  • So, say, the left of the 'I' in 'Introduction' should be aligned with the left of the '2' in the second subsection? Or the left of 'Lorem' should be aligned with the left of the '2'? Or ...? – cfr Feb 19 '18 at 17:26
3

Is this what you want? It all relies on the \llap command, which inserts its argument to the left of the current point on the line without moving the latter.

\documentclass[a4paper, 11pt]{article}
\usepackage[margin=2cm]{geometry} % changes the margin
\usepackage{enumitem}
\usepackage{titlesec}
\usepackage{indentfirst}
\usepackage{blindtext}

\renewcommand\thesection{\Alph{section}.}
\renewcommand\thesubsection{\arabic{subsection}.}
\titleformat{\section}
{\normalfont\fontsize{11}{.5em}\bfseries}{\llap{\thesection\hskip0.67em}}{0em}
    {}
\titleformat{\subsection}
{\normalfont\fontsize{11}{.5em}\selectfont}{\thesubsection}{.5em}
    {}
\titlespacing % starred version: first paragraph is not indented
{\subsection} % <command>
{0em} % <left>
{.4em} % <before-sep>
{.3em} % <after-sep>

\begin{document}

\section{Introduction}
\subsection{Subsection One}
    \begin{itemize} [leftmargin=1.3cm,topsep=0pt,itemsep=0pt,parsep=0pt,partopsep=0pt]
        \item some item here and there
        \item some item here and there
    \end{itemize}

\subsection{Subsection Two}
\setlength\parindent{.85cm} \blindtext

\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.