我目前在大学里使用以下布局进行每周练习:
\documentclass[a4paper, 12pt]{article}
\usepackage{titlesec}
\usepackage{lipsum}
% section title format and spacing
\titleformat{\subsection}[hang]{\sffamily\Large}{Exercise \arabic{section}.\arabic{subsection}}{0pt}{}[]
\titleformat{\subsubsection}[runin]{}{(\alph{subsubsection})}{0pt}{}[]
\titlespacing{\subsubsection}{0pt}{0.5em}{0.75em}
% subsubsection indentation
\let\svsubsubsection\subsubsection
\def\subsubsection{\leftskip1em\svsubsubsection}
\begin{document}
\setcounter{section}{1}
\subsection{}
\subsubsection{}
\lipsum[1-2]
\subsubsection{}
\[ some\ equation \]
\subsection{}
\end{document}
我怎样才能使\[ \]
数学环境从小节的第一行开始?
答案1
您可以使用以下aligned
环境:
代码:
\documentclass[a4paper, 12pt]{article}
\usepackage{titlesec}
\usepackage{lipsum}
\usepackage{mathtools}% <-- better to load this (it also loads amsmath)
% section title format and spacing
\titleformat{\subsection}[hang]{\sffamily\Large}{Exercise \arabic{section}.\arabic{subsection}}{0pt}{}[]
\titleformat{\subsubsection}[runin]{}{(\alph{subsubsection})}{0pt}{}[]
\titlespacing{\subsubsection}{0pt}{0.5em}{0.75em}
% subsubsection indentation
\let\svsubsubsection\subsubsection
\def\subsubsection{\leftskip1em\svsubsubsection}
\begin{document}
\setcounter{section}{1}
\subsection{}
\subsubsection{}
\lipsum[1-2]
\subsubsection{}
$\begin{aligned}[t]
F &= ma \\
E &= mc^2
\end{aligned}$
\subsection{}
\end{document}
答案2
enumerate
我认为使用环境会更容易、更简单特别指定参数。以下是可能的代码:
\documentclass[a4paper, 12pt]{article}
\usepackage{amsmath, nccmath}
\usepackage{enumitem}
\usepackage{titlesec}
\usepackage{lipsum}
% section title format and spacing
\titleformat{\subsection}[hang]{\sffamily\Large}{Exercise \arabic{section}.\arabic{subsection}}{0pt}{}[]
\titleformat{\subsubsection}[runin]{}{(\alph{subsubsection})}{0pt}{}[]
\titlespacing{\subsubsection}{0pt}{0.5em}{0.75em}
% subsubsection indentation
\let\svsubsubsection\subsubsection
\def\subsubsection{\leftskip1em\svsubsubsection}
\begin{document}
\setcounter{section}{1}
\subsection{}
\begin{enumerate}[wide = 0.6em, label=(\alph*), leftmargin=*]
\item \lipsum[1-2]
\item\leavevmode\vspace{-\baselineskip}\useshortskip \[ \text{some equation} \]
\lipsum[11]
\end{enumerate}
\subsection{}
\end{document}