制表符和字体大小更改

制表符和字体大小更改

作为上一个问题的后续 结合制表符和字体更改时的段落分隔符 我需要在环境中输入代码片段tabbing,但有时我需要更改字体大小以编写这些片段,如下所示

\documentclass[11pt,a4paper]{article}

\newenvironment{sftabbing}
  {\sffamily\tabbing}
  {\endtabbing}

\newenvironment{sfsmtabbing}
  {\relax\sffamily\small\tabbing}
  {\endtabbing}

\newenvironment{sfscstabbing}
  {\sffamily\scriptsize\tabbing}
  {\endtabbing}

\begin{document}

First paragraph blah blah blah blah blah blah blah blah blah blah blah blah 
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
\begin{sftabbing}
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some text
\end{sftabbing}
first paragraph continues here blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 

Second paragraph blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
\begin{sfsmtabbing}
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some text
\end{sfsmtabbing}
second paragraph continues here blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 

Third paragraph blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
\begin{sfscstabbing}
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some text
\end{sfscstabbing}
third paragraph continues here blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 

\end{document}

问题是我为此定义的环境不会使字体大小在环境中发生局部改变,因此封闭段落中行与行之间的间距也会改变。

答案1

我将使用一个环境和一个可选参数;如果没有指定可选参数,则环境不会改变字体大小。

但是,由于必须在tabbing环境启动之前给出大小声明,由于制表单元格形成组,我们需要终止当前段落。

\documentclass[11pt,a4paper]{article}

\newenvironment{sftabbing}[1][]
  {\par\sffamily#1\tabbing}
  {\endtabbing}

\newcommand{\blah}{blah blah blah blah blah blah blah blah blah blah blah blah 
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah}


\begin{document}

First paragraph \blah
\begin{sftabbing}
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some text
\end{sftabbing}
first paragraph continues here \blah

Second paragraph \blah
\begin{sftabbing}[\small]
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some text
\end{sftabbing}
second paragraph continues here \blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 

Third paragraph \blah
\begin{sftabbing}[\scriptsize]
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some text
\end{sftabbing}
third paragraph continues here \blah 

\end{document}

在此处输入图片描述

答案2

字体大小是环境本地的,但您在结束上一段之前更改了基线跳过。

\newenvironment{sftabbing}
  {\par\sffamily\tabbing}
  {\endtabbing\par}

\newenvironment{sfsmtabbing}
  {\par\relax\sffamily\small\tabbing}
  {\endtabbing\par}

\newenvironment{sfscstabbing}
  {\par\sffamily\scriptsize\tabbing}
  {\endtabbing\par}

相关内容