Can I use adjustwidth for my purpose?
I can propose this. As what you want is not quite clear to me, I hope it will be close to what you want.
First, I don't use the first \hangindent
. I increased the left margin instead (by about 2 em
) and made the section number go into the margin, with the titlesec
package.
Next I used the capabilities of enumitem
, in particular the resume
funnctionality (stop an enumerate environment and resume it later, with the same layout parameters) and the notion of series
(environments which share a common formatting and counter).
Last, I redefined \thesection
in a correct way, which doesn't have a side-effect in cross-references. What yoou want to gave is obtained within the \titleformat
command. I replaced your manually numbered horizontal list with a tasks
environment, with an automatic numbering. You'll find the details in the documentations of these packages.
\documentclass[12pt,a4paper,openany,fleqn]{book}
\usepackage[margin=2.8cm, top=2cm, showframe]{geometry}
\usepackage{amsmath}
\usepackage[no-math]{fontspec}
%\usepackage[fancyhdr,noindent]{ctexcap}
%\usepackage{xeCJK}
%\setCJKmainfont{Times New Roman}
\setmainfont{Times New Roman}
\linespread{1.6}
\parindent = 0 pt
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}}
%\CTEXsetup[format={\large},beforeskip={3.5ex},afterskip={0.3ex plus 0.1ex},aftername={}]{section}
\usepackage{changepage}
\usepackage{enumitem, tasks}
\usepackage{titlesec}
\usepackage{bm}
\renewcommand{\thesection}{\arabic{section}}
\makeatletter
\titleformat{\section}[hang]{\normalfont\Large\bfseries}{(\thesection)}{1em}{}
\titlespacing{\section}{-2em} {-3.5ex \@plus -1ex \@minus -.2ex}{2.3ex \@plus.2ex}%
\makeatother
\begin{document}
\section{Section Title:}
\begin{enumerate}[label =(\roman*), leftmargin =2em, nosep, before =\textbf{Discuss}]
\item discuss something
\item discuss something
\end{enumerate}
Now we gonna think of some case. Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah\\
\begin{enumerate}[label =(\alph*), font =\bfseries, wide=0pt, leftmargin=2em, labelsep =* , nosep, before =\textbf{Discuss}, series=cases]
\item \textbf{Case $ \bm{a > 1} $: }
In this case, we know that blah blah blah. (Here may have many words, tables or figures.)
Some table:
\begin{tasks}[counter-format =(tsk[1]), item-indent =0em, label-offset=0.5em](3)
\task $a^m · a^n=a^{m+n}$
\task* $\dfrac{a^m}{a^n}=a^{m-n}$\quad ($m>n,~a ≠ 0$)
\task $(a^m)^n=a^{mn}$
\task $(ab)^n=a^n · b^n$
\task $\left(\dfrac{a}{b}\right)^n=\dfrac{a^n}{b^n}$\quad($b ≠ 0$)
\end{tasks}
\end{enumerate}
\begin{enumerate}[label =(\roman*), leftmargin =2em, nosep, before =\textbf{Discuss}]
\item Here the position of item is not the same as above, why?
\end{enumerate}
\begin{enumerate}[resume*=cases, before = \relax]
\item \textbf{Case $\bm{a<1}$:}
Some words. Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah.
\end{enumerate}
\end{document}
Related videos on Youtube
Eric
Updated on May 08, 2020Comments
-
Eric over 3 years
I want to typeset something with level indent. For example, beneath the (a) Case and (b) Case (the orange region). I first tried
{\leftskip 2em ...}
, but this just affects words, neither tabular nor figures. And also minipage is not ideal for me, since I want it be allowable to through pages if needed.So I then tried
adjustwidth
(packagechangepage
)Questions
- Is it good to use
adjustwidth
enviroment for my purpose? Is there other better solutions? - Why does the left margin in the
adjustwidth
environment is not directly move right to 2em as I expected(namely, I expect (i) is right beneath "D"iscuss as above did)?
Code:
\documentclass[12pt,a4paper,openany,fleqn]{book} \usepackage[margin=2cm, top=2cm]{geometry} \usepackage{amsmath} \usepackage[no-math]{fontspec} \usepackage[fancyhdr,noindent]{ctexcap} \usepackage{xeCJK} \setCJKmainfont{Times New Roman} \linespread{1.6} \parindent = 0 pt \usepackage{fancyhdr} \pagestyle{fancy} \fancyhf{} \fancyfoot[C]{\thepage} \renewcommand{\headrulewidth}{0pt} \renewcommand{\footrulewidth}{0pt} \fancypagestyle{plain}{% \fancyhf{} % clear all header and footer fields \fancyfoot[C]{\thepage} \renewcommand{\headrulewidth}{0pt} \renewcommand{\footrulewidth}{0pt}} \CTEXsetup[format={\large},beforeskip={3.5ex},afterskip={0.3ex plus 0.1ex},aftername={}]{section} \renewcommand{\thesection}{(\arabic{section})~} \newcommand{\allindent}{\hangindent = 2em\hangafter = 0} \newcommand{\doubleindent}{\hangindent = 4em\hangafter = 0} \newcounter{iItemcounter} \newcommand{\iItem}[2][4em]{ \setcounter{iItemcounter}{0} \begin{list}{(\roman{iItemcounter})}{\usecounter{iItemcounter}\itemsep=0pt\parsep=0pt\parskip=0pt\topsep=0pt \leftmargin = #1}{#2}\end{list} } \newcommand{\discussItem}[1]{ \par\allindent \textbf{Discuss:} \iItem{#1} } \usepackage{changepage} \begin{document} \section{Section Title:} \allindent This is level one. \discussItem{\item discuss something \item discuss something} \allindent Now we gonna think of some case. Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah\\ \textbf{(a)Case $a>1$:} \begin{adjustwidth}{4em}{} In this case, we know that blah blah blah. (Here may have many words, tables or figures.)\\ Some table: \begin{tabular}[t]{lll} (1)~$a^m\cdot a^n=a^{m+n}$&(2)~$\frac{a^m}{a^n}=a^{m-n}$\quad($m>n,~a\neq 0$) &(3)~$(a^m)^n=a^{mn}$ \\ (4)~$(ab)^n=a^n\cdot b^n$ &(5)~$\left(\frac{a}{b}\right)^n=\frac{a^n}{b^n}$\quad($b\neq 0$) & \end{tabular} \discussItem{\item Here the position of item is not the same as above, why?} \end{adjustwidth} \allindent \textbf{(b)Case $a<1$:} \doubleindent Some words. Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah . \end{document}
-
Bernard over 6 yearsWhy reinvent the wheel? All this can be done rather simply with the
enumitem
package -
Eric over 6 years@Bernard I just searched the document of it, but it is difficult for me to rewrite it by that package. Can you help me with an example?
-
Bernard over 6 yearsI don't have time at the moment, but I'll post an example later if no one else has.
- Is it good to use
-
Eric over 6 yearsThanks. By the way, is
adjustwidth
not proper for this case? If so, why? Nested lists takes time to write, read and think for me because of its (a little bit more complicated) logic. Hence it is hard to maintain. I think thinking as "adjusting the left margin" seems more straightforward. (But maybe the implement of theadjustwidth
is exactly by nested list?) If the standard solution to typeset a document with levels as this post is nested lists, then I will persuade myself to get used to it. -
Bernard over 6 yearsWell, I wouldn't say
adjustwidth
is not a good solution at the outer level. What I think is not good is all thosehangindent
adjustments within the textbody. It is better to define a document structure via environments, and I must say I was not too sure of the structure, lacking the context. Note the enumerate environments I defined, with very specific parameters, can be turned into new enumerate-like environments in the preamble, using\newlist{enumerate}{mycustomlist}
and\setlist[mycustomlist]{…}
. This will make the structure clearer.