新的基于报价的环境结束间距

新的基于报价的环境结束间距

为了插入引文,该文件使用了quote基于\newenvironmentx

\newenvironmentx{QUOTE}[1][1=.]{%
  \begin{quote}%
  \tiny\noindent%
  \gdef\parQ{#1}``%
}{\parQ''%
  \normalsize%
  \end{quote}%
}

引用应该在LaTex引号内,并且默认情况下,最后一段以点结尾。

否则,当使用 指出引用时\cite,引文的排版如下:

\begin{QUOTE}[~--~(\cite{etc}, pp.~2).]%
... is mainly implemented by means of ... systems%
\end{QUOTE}

因此我期望"... systems - ([1], pp. 2).",在破折号周围只有一个空格,因此要特别注意用百分号结束行,注释掉换行符;相反,会放更多的空格,结果就像"... systems - ([1], pp. 2)."

我怎样才能避免\newenvironmentx{QUOTE}最后一段中的最后一个字符后面紧跟着(默认点或)绑定空格(波浪号)?

已编辑

好的,这是mwe.dtx由此得出的mwe.cls结果latex mwe.ins

% \iffalse    (METACOMMENT)
%%
%% ---------------------------------------------------------------------
%%
%% Document class `mwe' to use with LaTeX 2e.
%%
%% ---------------------------------------------------------------------
%%
% \fi
%
% \CheckSum{370}
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
% ^^A \MakeShortVerb{\|}
% \section{Internals}
%
%    \begin{macrocode}
%<class>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
%    \end{macrocode}
%
% \iffalse (Don't show this in the doc).
%<*driver>
         \ProvidesFile{mwe.drv}
%</driver>
% \fi
%    \begin{macrocode}
%<class>\ProvidesClass{./mwe}
        [2013/03/29 v1.01
%<class>        MWE tex.stackexchange.com class]
%    \end{macrocode}
% \iffalse (Omitted from the doc)
%<*driver>
]
%</driver>
% \fi
%
% \subsection{Driver for this document}
%
% The \dst{} program will extract the following driver from this file:
%    \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
%\DisableCrossrefs % Say \DisableCrossrefs if index is ready
\RecordChanges
%\OnlyDescription % Comment out for implementation details
\CodelineIndex
\begin{document}
\end{document}
%</driver>
%    \end{macrocode}
% \raggedbottom
%    \begin{macrocode}
\IfFileExists{suffix.sty}{%
  \RequirePackage{suffix}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The suffix package was not found.}{%%%%%%%%%%%%%
    The suffix package allows for starred commands.%
  }}
\IfFileExists{tokenizer.sty}{%
  \RequirePackage[trim]{tokenizer}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The tokenizer package was not found.}{%%%%%%%%
    The tokenizer package allows list processing.%
  }}
\IfFileExists{xkvltxp.sty}{%
  \RequirePackage{xkvltxp}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%
    The xkvltxp package was not found.}{%%%%%
    The xkvltxp package is bound to xkeyval.%
  }}
\IfFileExists{xkeyval.sty}{%
  \RequirePackage{xkeyval}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The xkeyval package was not found.}{%%%%%%%%%%%%%%%%%%
    The xkeyval package will anyway be loaded implicitly.%
  }}
\IfFileExists{xargs.sty}{%
  \RequirePackage{xargs}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The xargs package was not found.}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The xargs package is mandatory with commands and environments.%
  }}
\IfFileExists{xifthen.sty}{%
  \RequirePackage{xifthen}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The xifthen package was not found.}{%%%%%%%%%%%%%%%%%%%%
    The xifthen package is needed for labels, references...%
  }}
%    \end{macrocode}
%    \begin{macrocode}
% \begin{macro}{\mwe@lst@nul}
% \begin{macro}{\mwe@def@nul}
% \begin{macro}{\mwe@lst@set}
% \begin{macro}{\mwe@def@set}
% \begin{macro}{\mwe@lst@add}
% \begin{macro}{\mwe@lst@rem}
% \begin{macro}{\mwe@lst@r@m}
% \begin{macro}{\mwe@lst@pop}
% \begin{macro}{\mwe@lst@p@p}
% initialize an empty list
\newcommandx\mwe@lst@nul[2][2=mwe@]{\mwe@lst@set{}{#1}[#2]}
% initialize empty definition macros
\let\mwe@def@nul\mwe@lst@nul
% create an empty list from a given list
\newcommandx%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mwe@lst@set[3][addprefix=\global,3=mwe@]{%%%%%%%%%%%
\expandafter\protected@xdef\csname#3#2\endcsname{#1}}
% initialize definition macros
\let\mwe@def@set\mwe@lst@set
% add item to the top of the list (replacement for \in@)
\newcommandx\mwe@lst@add[3][3=mwe@]{%
  \ifx\\#1\\\else\mwe@empt@if*{\@nameuse{#3#2}}{\@expandtwoargs%
    \mwe@lst@set{#1}{#2}[#3]}{\@expandtwoargs%%%%%%%%%%%%%%%%%%%
    \mwe@lst@set{#1,\@nameuse{#3#2}}{#2}[#3]}\fi%%%%%%%%%%%%%%%%
}
% remove specified item #1 from the in/out list #2
\newcommandx\mwe@lst@rem[3][3=mwe@]{%
  \ifx\\#1\\\else\mwe@NOT@empt@if{\@nameuse{#3#2}}{%
    \mwe@lst@r@m{#1}{#2}[#3]}\fi%%%%%%%%%%%%%%%%%%%%
}
% helper for both above and below (employment of \@removeelement)
\newcommandx\mwe@lst@r@m[3][3=mwe@]{\@expandtwoargs%%%%%%%%%%%%%
  \@removeelement{#1}{\@nameuse{#3#2}}{\mwe@v@r}\@expandtwoargs%
  \mwe@lst@set{\mwe@v@r}{#2}[#3]%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
% remove first item from the list #2 and save the item in command #1
\newcommandx\mwe@lst@pop[3][3=mwe@]{%
  \mwe@empt@if*{\@nameuse{#3#2}}{%
    \mwe@def@nul{#1}[#3]}{\@expandtwoargs%%%%%%%%%%%
    \mwe@lst@p@p{\@nameuse{#3#2}}{,}\@expandtwoargs%
    \mwe@lst@r@m{\mwe@var}{#2}[#3]\@expandtwoargs%%%
    \mwe@def@set{\mwe@var}{#1}[#3]}%
}
% helper for \mwe@lst@pop above (employment of \GetTokens)
\newcommand\mwe@lst@p@p[2]{\mwe@lst@get{#1#2}}
% get tokens from a list: head is \mwe@var; tail is \mwe@v@r
\newcommandx\mwe@lst@get[4]%%%%%%%%%%%%%%%%%%%%%
[2=var,3=v@r,4=mwe@]{\GetTokens{#4#2}{#4#3}{#1}}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%    \end{macrocode}
% \begin{macro}{\mwe@empt@}
%    \begin{macrocode}
% positive \equal{}
\newtest\mwe@empt@[1]{\equal{#1}{}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\mwe@NOT@if}
% \begin{macro}{\mwe@NOT@empt@if}
% \begin{macro}{\mwe@empt@if}
% \begin{macro}{\mwe@empt@if*}
%    \begin{macrocode}
% negative \ifthenelse to have it work with the above
\newcommand\utt@NOT@if[2]{\ifthenelse{#1}{}{#2}}
% derived \NOT if \equal{}
\newcommand\mwe@NOT@empt@if[2]{\mwe@NOT@if{\mwe@empt@{#1}}{#2}}
% positive \ifthenelse through \equal{}
\newcommand\mwe@empt@if[2]{\mwe@empt@if*{#1}{#2}{}}
% positive \ifthenelse through \equal{} (two branches)
\WithSuffix%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\mwe@empt@if*[3]{\ifthenelse{\mwe@empt@{#1}}{#2}{#3}}
% positive \ifthenelse through \equal
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%    \begin{macrocode}
\LoadClass[a4paper,10pt,twoside,openright]{report}[2007/10/19]
\IfFileExists{fontenc.sty}{%
  \RequirePackage[T1]{fontenc}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The fontenc package was not found.}{%%%%%%%%%%%%
    The fontenc package is required for some fonts.%
  }}
\IfFileExists{inputenc.sty}{%
  \RequirePackage[utf8]{inputenc}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The inputenc package was not found.}{%%%%%%%%
    The inputenc package provides UTF-8 unicode.%
  }}
\IfFileExists{multicol.sty}{%
  \RequirePackage{multicol}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The multicol package was not found.}{%%%%%%%
    The multicol package is required in tables.%
  }}
\IfFileExists{multirow.sty}{%
  \RequirePackage{multirow}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The multirow package was not found.}{%%%%%%%%
    The multirow package is required for tables.%
  }}
%    \end{macrocode}
%    \begin{macrocode}
% discern "enumerate" environments (true) from the rest (false)
\newif\if@mwe@some@that@\@mwe@some@that@false
% list of true|false values implemented as stack for \begin|\end
\mwe@lst@nul{some@bels}
% temporary store false or true popped off the \mwe@some@bels
\mwe@def@nul{some@bebl}
% save command \begin original (\LaTeX) definition
\let\mwe@begin\begin
% redefine \begin but invoke previous code
\def\begin{\mwe@some@mark\mwe@begin}
% save command \end original (\LaTeX) definition
\let\mwe@end\end
% redefine \end but invoke previous code
\def\end{\mwe@some@m@rk\mwe@end}
% push boolean value gotten from flag onto the "begin/end" stack-list
\newcommandx\mwe@some@mark[7][1=true,2=bels%%%%%%%%
,3=that,4=some@,5=mwe,6=@,7=false]{\@expandtwoargs%
\mwe@lst@add{\if@mwe@some@that@#1\else#7\fi}{#4#2}%
\expandafter\global\csname#6#5#6#4#3#6#7\endcsname}
% pop boolean value from the "begin/end" stack-list and set flag
\newcommandx\mwe@some@m@rk[6]%%%%%%%%%%%%%%%
[1=bebl,2=bels,3=that,4=some@,5=mwe,6=@]{%%%
\mwe@lst@pop{#4#1}{#4#2}\expandafter\global%
\csname#6#5#6#4#3#6\mwe@some@bebl\endcsname}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}

以下mwe.texmwe.pdf结果pdflatex -shell-escape mwe.tex

\documentclass{./mwe}

\newenvironment{QUOTE}[1][1=.]{%
  \begin{quote}%
  \tiny\noindent
  \def\parQ{#1}``\ignorespaces
}{\parQ''%
  \end{quote}%
}

\begin{document}

MAIN TEXT: quotation

\begin{QUOTE}[~--~(\ldots, pp.~2).]%%%%%%%%%%%%%%%
... is mainly implemented by means of ... systems%
\end{QUOTE}

CONTINUES

\begin{table}[htb]
  \begin{center}\begin{tabular}{|c|l|c|c|c|}
    \hline \multirow{4}{*}{1}          &&&& \\ %%%%%%%%%%%%%%%%%%%%%%
      & A text spanning on two rows     & May &          &  seven  \\
      &  and centered in four rows      &     & December &    7    \\
    &&&& \\ \hline %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \end{tabular}\end{center}
  \caption{Projected timelines}
\end{table}

\end{document}

不仅如此QUOTE,所有其他环境都会受到影响:tabular图案中的左/右线{|...|}总是在左侧添加两条平行的未完成线。

tabular重新定义时会受到影响,\begin/\endQUOTE与后者重新定义一起工作,但不喜欢\mwe@some@mark/\mwe@some@m@rk扩展。我没有插入mwe.insltxdoc.cfg。感谢您进一步了解这一点。塞巴斯蒂安

%%
%% This is file `mwe.cls',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% mwe.dtx  (with options: `class')
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from mwe.cls.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file mwe.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%%
%% ---------------------------------------------------------------------
%%
%% Document class `mwe' to use with LaTeX 2e.
%%
%% ---------------------------------------------------------------------
%%
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{./mwe}
[2013/03/29 v1.01
 MWE tex.stackexchange.com class]
\IfFileExists{suffix.sty}{%
  \RequirePackage{suffix}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The suffix package was not found.}{%%%%%%%%%%%%%
    The suffix package allows for starred commands.%
  }}
\IfFileExists{tokenizer.sty}{%
  \RequirePackage[trim]{tokenizer}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The tokenizer package was not found.}{%%%%%%%%
    The tokenizer package allows list processing.%
  }}
\IfFileExists{xkvltxp.sty}{%
  \RequirePackage{xkvltxp}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%
    The xkvltxp package was not found.}{%%%%%
    The xkvltxp package is bound to xkeyval.%
  }}
\IfFileExists{xkeyval.sty}{%
  \RequirePackage{xkeyval}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The xkeyval package was not found.}{%%%%%%%%%%%%%%%%%%
    The xkeyval package will anyway be loaded implicitly.%
  }}
\IfFileExists{xargs.sty}{%
  \RequirePackage{xargs}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The xargs package was not found.}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The xargs package is mandatory with commands and environments.%
  }}
\IfFileExists{xifthen.sty}{%
  \RequirePackage{xifthen}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The xifthen package was not found.}{%%%%%%%%%%%%%%%%%%%%
    The xifthen package is needed for labels, references...%
  }}
\newcommandx\mwe@lst@nul[2][2=mwe@]{\mwe@lst@set{}{#1}[#2]}
\let\mwe@def@nul\mwe@lst@nul
\newcommandx%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mwe@lst@set[3][addprefix=\global,3=mwe@]{%%%%%%%%%%%
\expandafter\protected@xdef\csname#3#2\endcsname{#1}}
\let\mwe@def@set\mwe@lst@set
\newcommandx\mwe@lst@add[3][3=mwe@]{%
  \ifx\\#1\\\else\mwe@empt@if*{\@nameuse{#3#2}}{\@expandtwoargs%
    \mwe@lst@set{#1}{#2}[#3]}{\@expandtwoargs%%%%%%%%%%%%%%%%%%%
    \mwe@lst@set{#1,\@nameuse{#3#2}}{#2}[#3]}\fi%%%%%%%%%%%%%%%%
}
\newcommandx\mwe@lst@rem[3][3=mwe@]{%
  \ifx\\#1\\\else\mwe@NOT@empt@if{\@nameuse{#3#2}}{%
    \mwe@lst@r@m{#1}{#2}[#3]}\fi%%%%%%%%%%%%%%%%%%%%
}
\newcommandx\mwe@lst@r@m[3][3=mwe@]{\@expandtwoargs%%%%%%%%%%%%%
  \@removeelement{#1}{\@nameuse{#3#2}}{\mwe@v@r}\@expandtwoargs%
  \mwe@lst@set{\mwe@v@r}{#2}[#3]%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
\newcommandx\mwe@lst@pop[3][3=mwe@]{%
  \mwe@empt@if*{\@nameuse{#3#2}}{%
    \mwe@def@nul{#1}[#3]}{\@expandtwoargs%%%%%%%%%%%
    \mwe@lst@p@p{\@nameuse{#3#2}}{,}\@expandtwoargs%
    \mwe@lst@r@m{\mwe@var}{#2}[#3]\@expandtwoargs%%%
    \mwe@def@set{\mwe@var}{#1}[#3]}%
}
\newcommand\mwe@lst@p@p[2]{\mwe@lst@get{#1#2}}
\newcommandx\mwe@lst@get[4]%%%%%%%%%%%%%%%%%%%%%
[2=var,3=v@r,4=mwe@]{\GetTokens{#4#2}{#4#3}{#1}}
\newtest\mwe@empt@[1]{\equal{#1}{}}
\newcommand\utt@NOT@if[2]{\ifthenelse{#1}{}{#2}}
\newcommand\mwe@NOT@empt@if[2]{\mwe@NOT@if{\mwe@empt@{#1}}{#2}}
\newcommand\mwe@empt@if[2]{\mwe@empt@if*{#1}{#2}{}}
\WithSuffix%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\mwe@empt@if*[3]{\ifthenelse{\mwe@empt@{#1}}{#2}{#3}}
\LoadClass[a4paper,10pt,twoside,openright]{report}[2007/10/19]
\IfFileExists{fontenc.sty}{%
  \RequirePackage[T1]{fontenc}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The fontenc package was not found.}{%%%%%%%%%%%%
    The fontenc package is required for some fonts.%
  }}
\IfFileExists{inputenc.sty}{%
  \RequirePackage[utf8]{inputenc}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The inputenc package was not found.}{%%%%%%%%
    The inputenc package provides UTF-8 unicode.%
  }}
\IfFileExists{multirow.sty}{%
  \RequirePackage{multirow}}{%
  \ClassError{./mwe}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    The multirow package was not found.}{%%%%%%%%
    The multirow package is required for tables.%
  }}
\newif\if@mwe@some@that@\@mwe@some@that@false
\mwe@lst@nul{some@bels}
\mwe@def@nul{some@bebl}
\let\mwe@begin\begin
\def\begin{\mwe@some@mark\mwe@begin}
\let\mwe@end\end
\def\end{\mwe@some@m@rk\mwe@end}
\newcommandx\mwe@some@mark[7][1=true,2=bels%%%%%%%%
,3=that,4=some@,5=mwe,6=@,7=false]{\@expandtwoargs%
\mwe@lst@add{\if@mwe@some@that@#1\else#7\fi}{#4#2}%
\expandafter\global\csname#6#5#6#4#3#6#7\endcsname}
\newcommandx\mwe@some@m@rk[6]%%%%%%%%%%%%%%%
[1=bebl,2=bels,3=that,4=some@,5=mwe,6=@]{%%%
\mwe@lst@pop{#4#1}{#4#2}\expandafter\global%
\csname#6#5#6#4#3#6\mwe@some@bebl\endcsname}
\endinput
%%
%% End of file `mwe.cls'.

答案1

“开始部分”开始一个段落,因此后面的空格\begin{QUOTE}不会被丢弃。

\newenvironmentx{QUOTE}[1][1=.]{%
  \begin{quote}%
  \tiny\noindent
  \def\parQ{#1}``\ignorespaces
}{\parQ''%
  \end{quote}%
}

无需说\normalsize,也无需使用\gdef

也没有必要使用\newenvironmentx

\newenvironment{QUOTE}[1][.]{%

也会这么做。

相关内容