我打算制作一个命令来缩进\begin{pinden}{3cm}
和之间的所有文本\end{pinden}{3cm}
。但实际情况是,出现的第一个文本没有缩进,但其余文本都正确缩进。
%% lexi.sty
\usepackage{etoolbox}
\usepackage{xcolor}
\makeatletter
\newlength\pinden@len
\newenvironment{pinden}[1]{
\setlength{\pinden@len}{\the\parindent}
\setlength{\parindent}{#1}
}{
\setlength{\parindent}{\pinden@len}
}
\makeatother
因此
\documentclass[12pt]{article}
\usepackage[b5paper,body={13cm,18cm}]{geometry}
\usepackage[italian,french,spanish,icelandic,english]{babel}
\usepackage{etoolbox}
\usepackage{xcolor}
\usepackage{lexi}
\begin{document}
\newtoggle{show-language-orthography}
\toggletrue{show-language-orthography}
\iftoggle{show-language-orthography}{
\begin{otherlanguage*}{icelandic}
\newpage
\section{Icelandic Orthography}
\subsection{Icelandic Alphabet - Majuscule forms}
\begin{pinden}{3cm}
a á b d ð e é f g h i í j k l m n o ó
p r s t u ú v x y ý þ æ ö
p r s t u ú v x y ý þ æ ö
\end{pinden}
\end{otherlanguage*}
}{}
\end{document}
给出
a á b d ð e é f g h i í j k l m n o ó
p r s t u ú v x y ý þ æ ö
p r s t u ú v x y ý þ æ ö
答案1
您不需要保存和恢复的值
\parindent
,因为您在环境中所做的任何更改pinden
都会在pinden
结束后被丢弃。章节标题后的第一个段落没有缩进。
你正在试图重新发明轮子。
\documentclass[12pt]{article}
\usepackage[b5paper,body={13cm,18cm}]{geometry}
\usepackage[T1]{fontenc}
\usepackage[italian,french,spanish,icelandic,english]{babel}
\makeatletter
\newenvironment{pinden}[1]{%
\@afterindenttrue
\setlength\parindent{#1}%
}{\par}
\makeatother
\begin{document}
\begin{otherlanguage*}{icelandic}
\section{Icelandic Orthography}
\subsection{Icelandic Alphabet - Majuscule forms}
\begin{pinden}{3cm}
a á b d ð e é f g h i í j k l m n o ó
p r s t u ú v x y ý þ æ ö
p r s t u ú v x y ý þ æ ö
\end{pinden}
\end{otherlanguage*}
\end{document}
那么第 3 点呢?
\documentclass[12pt]{article}
\usepackage[b5paper,body={13cm,18cm}]{geometry}
\usepackage[T1]{fontenc}
\usepackage[italian,french,spanish,es-noquoting,icelandic,english]{babel}
\newenvironment{pinden}[1]{%
\list{}{%
\leftmargin=#1\relax
\rightmargin=0pt
\topsep=0pt
\partopsep=0pt
\parsep=0pt
\itemsep=0pt
}\item\relax
}{\endlist}
\begin{document}
\begin{otherlanguage*}{icelandic}
\section{Icelandic Orthography}
\subsection{Icelandic Alphabet - Majuscule forms}
\begin{pinden}{3cm}
a á b d ð e é f g h i í j k l m n o ó
p r s t u ú v x y ý þ æ ö
p r s t u ú v x y ý þ æ ö
\end{pinden}
\end{otherlanguage*}
\end{document}
输出是一样的。
有了包就更容易了quoting
,比如说
\newenvironment{pinden}[1]{%
\quoting[indentfirst=false,vskip=0pt,leftmargin=#1,rightmargin=0pt]%
}{\endquoting}
但不幸的是,这与不兼容babel-spanish
。