0

I tries to add some text before and after using itemize. However, they are not aligned. How to align after text with before text?

\documentclass[UTF8]{ctexart}
\begin{document}
\section{A}
\subsection{A-A}
before text
\begin{itemize}
\item a
\item b
\end{itemize}
after text
\end{document}

enter image description here

  • 2
    Welcome to TEX.SE! You could try with \noindent before text but this is not the behaviour of the standard classes. Please provide a full minimal working example which reproduces the issue, possibly starting with \documentclass{...} and ending with \end{document}. – campa Jun 20 '18 at 07:46
  • Does \noindent or \setlength\parindent{0pt} in the preamble help? – Bobyandbob Jun 20 '18 at 07:47
  • It aligns properly with article class.. which class are you using?? Add a mwe. – David Jun 20 '18 at 07:53
  • I used ctexart. I found it also works. but they are left aligned with section number. It works if I use flushleft. but how if there anyway I can add the indent? – michael Jun 20 '18 at 08:02
  • 1
    Post a complete minimal working example (MWE) and we might be able to help you. Something defines the section titles to not prevent the first paragraph to be indented, which is not the default behaviour of the standard classes. But without compilable code which results in the above picture, we can not help you any further (at least I won't and most other users most likely also won't). – Skillmon Jun 20 '18 at 08:20
  • @Skillmon Thanks for your suggestion. I edit the picture the code, which was exactly same with what it ran – michael Jun 20 '18 at 12:15

1 Answers1

1

The ctexart sets the indent after the section title in \@startsection. There should be a key to change the behaviour, but sadly I don't understand Chinese, and the documentation seems to be in Chinese. The key should be anything related to the word afterindent, if you understand the documentation search for that.

Therefore the following hacks its way through ctexart:

\documentclass[UTF8]{ctexart}

\usepackage{xpatch}

\makeatletter
\xpatchcmd\@startsection{\@afterindenttrue}{\@afterindentfalse}{}
  {%
    \GenericError{}{Patching \noexpand\@startsection failed}{}
    {Read the manual of 'ctexart' and search for the key 'afterindent'.}%
  }
\makeatother

\begin{document}
\section{A}
\subsection{A-A}
before text
\begin{itemize}
\item a
\item b
\end{itemize}
after text
\end{document}
Skillmon
  • 60,462