我有这个MWE:
\documentclass{article}
\newcommand{\toleftmargin}[1]{?????}
\begin{document}
\toleftmargin{This text should be on the left margin and already is}
\begin{itemize}
\item Text
This text should be still indented
\toleftmargin{This text should be on the left margin}
\item Text
\begin{itemize}
\item Text
This text should be still indented
\toleftmargin{This text should be on the left margin}
\item Text
\end{itemize}
\item Text
\end{itemize}
\toleftmargin{This text should be on the left margin and already is}
\begin{enumerate}
\item Text
This text should be still indented
\toleftmargin{This text should be on the left margin}
\item Text
\begin{enumerate}
\item Text
This text should be still indented
\toleftmargin{This text should be on the left margin}
\item Text
\end{enumerate}
\item Text
\end{enumerate}
\end{document}
我应该创建命令\toleftmargin
,通过删除参数中给出的文本的缩进,将文本带到左边距。
我不知道该怎么做。有人知道吗?
答案1
在这种情况下,我认为代码片段就可以了。请注意,您至少需要一个\par
,第二个将被忽略。
\makeatletter
\newcommand{\toleftmargin}[1]{\par\noindent\hspace{-\@totalleftmargin}\parbox[t]{\textwidth}{#1}}
\makeatother