在https://tex.stackexchange.com/a/552557/13492\bigtimes
,展示了一种创建符号(用于家族的笛卡尔积)和\bigplus
符号(用于家族的笛卡尔和)的方法。
问题:
如何修改才能
\bigtimes
使不是有一个方形的形状,也就是说,两个笔划不是以直角交叉,从而使符号的宽度小于其高度。答案https://tex.stackexchange.com/a/552769/13492包括一个
\scalebox
水平缩放因子\scalefactor
,其值基本上是根据目标符号进行硬编码的。是否可以\scalefactor
修改代码以包含一个额外的参数,默认值为 1,作为水平缩放因子?考虑到预期用途,两个符号都采用下标和/或上标进行索引,是否不需要
\DeclareMathOperator
或\mathop
?如果是,应如何纳入;如果不是,为什么不呢?
来源:代码来自https://tex.stackexchange.com/a/552557/13492由我尝试使用两种不同的注释掉的方法进行补充,以实现目标 1。
\documentclass[fleqn]{article}
\usepackage{amsmath,pict2e}
\usepackage{iftex}
\ifTUTeX
\usepackage{unicode-math}
\setmainfont{TeX Gyre Termes}[Scale=1.0]
\setmathfont{TeX Gyre Termes Math}
\else
\usepackage{newtxtext,newtxmath}
\fi
\makeatletter
\newcommand{\my@big}[1]{%
\mathop{\vphantom{\sum}\mathpalette\my@makebig{#1}}\slimits@
}
\AtBeginDocument{%
\DeclareRobustCommand{\bigplus}{\DOTSB\my@big\my@plus}%
\DeclareRobustCommand{\bigtimes}{\DOTSB\my@big\my@times}%
}
\newcommand{\my@makebig}[2]{%
\vcenter{%
\sbox\z@{$\m@th#1\sum$}%
\setlength{\unitlength}{0.9\dimexpr\ht\z@+\dp\z@}%
\hbox{\kern0.1\wd\z@\my@draw{#1}{#2}\kern0.1\wd\z@}%
}%
}
\newcommand{\my@draw}[2]{%
\begin{picture}(1,1)
\linethickness{%
\ifx#1\displaystyle 1.2\fontdimen8\textfont3\else
\ifx#1\textstyle 1.1\fontdimen8\textfont3\else
\ifx#1\scriptstyle1\fontdimen8\scriptfont3\else
1\fontdimen8\scriptscriptfont3\fi\fi\fi
}%
#2
\end{picture}%
}
\newcommand{\my@plus}{%
\roundcap
\Line(0.5,0)(0.5,1)
\Line(0,0.5)(1,0.5)
}
\newcommand{\my@times}{%
\roundcap
\Line(0,0)(1,1)
\Line(0,1)(1,0)
}
%% Attempt #1 to try to reshape \bigtimes...
%% ...leaves too much space after \bigtimes...
%% ... and displaystyle puts sub- & super-scripts off-center
%\newcommand{\my@times}{%
% \roundcap
% \Line(0,0)(0.75,1)
% \Line(0,1)(0.75,0)
%}
%% Attempt #2 to reshape \bigtimes, using \scalebox instead ...
%% ... makes lines too thin and leaves too much space after \bigtmies...
%% ... and displaystyle puts sub- & super-scripts off-center:
%\newcommand{\my@@times}{%
% \roundcap
% \Line(0,0)(1,1)
% \Line(0,1)(1,0)
%}
%\usepackage{graphicx}
%\newcommand{\my@times}{%
% \scalebox{0.85}[1]{\my@@times}%
%}
\makeatother
\begin{document}
In-line $
\bigplus_{i\in I} X_i = \bigtimes_{j\in J} Y_i = \bigcup_{i\in I} Z_{i} = \bigcap_{n\in I} Z_{i}
$ here.
\[
\bigplus_{i\in I} X_i = \bigtimes_{j\in J} Y_i = \bigcup_{i\in I} Z_i = \bigcap_{n\in I} Z_{i}
\]
In-line $
\bigplus_{i=0}^{\infty} X_i = \bigtimes_{j=0}^{\infty} Y_i = \bigcup_{i=0}^{\infty} Z_{i} = \bigcap_{n=0}^{\infty} Z_{i}
$ here.
\[
\bigplus_{i=0}^{\infty} X_i = \bigtimes_{j=0}^{\infty} Y_i = \bigcup_{i=0}^{\infty} Z_i = \bigcap_{n=0}^{\infty} Z_{i}
\]
\end{document}
输出:显示的所有输出都是使用 XeLaTeX 生成的;如果使用 pdfLaTeX,结果会类似。
首先是使用原始代码的输出https://tex.stackexchange.com/a/552557/13492。
其次,如果使用 my 的输出Attempt 1
,则会在内联模式下留下太多空间\bigtimes
,并在显示模式下将子标和上标置于中心之外:
第三,如果使用 my 的输出Attempt 2
,也会在内联模式下留下太多空间\bigtimes
,并在显示模式下使子标和上标偏离中心:
答案1
通过创建单独的\my@narrowbig
、\my@narrowmakebig
、 和\my@narrowdraw
和\my@narrowtimes
命令,使用 0.75 宽和 1 高的绘图画布,我可以得到一个或多或少适合笛卡尔积的非平方\bigtimes
运算符号。同样,也可以得到一个\bigbox
盒子积的运算符号(在拓扑意义上)。
结果:
代码如下所示。
投诉:
- 在屏幕上查看时,新符号的笔画看起来不错;但在打印时,与 相比, 、 和 的笔画似乎太
\bigtimes
粗\bigsum
了一点。\bigbox
\bigcup
\bigcap
该如何修复? - 必须创建两组命令 — — 一组用于新的操作
\bigsum
符,另一组用于其他新的操作符,这似乎是一种极大的代码浪费。有没有什么方法可以合并这些代码?
修改后的源码:
\documentclass[fleqn]{article}
\usepackage{amsmath,pict2e}
\usepackage{iftex}
\ifTUTeX
\usepackage{unicode-math}
\setmainfont{TeX Gyre Termes}[Scale=1.0]
\setmathfont{TeX Gyre Termes Math}
\else
\usepackage{newtxtext,newtxmath}
\fi
\makeatletter
\newcommand{\my@big}[1]{%
\mathop{\vphantom{\sum}\mathpalette\my@makebig{#1}}\slimits@
}
\newcommand{\my@narrowbig}[1]{%
\mathop{\vphantom{\sum}\mathpalette\my@narrowmakebig{#1}}\slimits@
}
\AtBeginDocument{%
\DeclareRobustCommand{\bigplus}{\DOTSB\my@big\my@plus}%
%\DeclareRobustCommand{\bigtimes}{\DOTSB\my@big\my@times}%
\DeclareRobustCommand{\bigtimes}{\DOTSB\my@narrowbig\my@narrowtimes}%
\DeclareRobustCommand{\bigbox}{\DOTSB\my@narrowbig\my@narrowbox}%
}
\newcommand{\my@makebig}[2]{%
\vcenter{%
\sbox\z@{$\m@th#1\sum$}%
\setlength{\unitlength}{0.9\dimexpr\ht\z@+\dp\z@}%
\hbox{\kern0.1\wd\z@\my@draw{#1}{#2}\kern0.1\wd\z@}%
}%
}
\newcommand{\my@draw}[2]{%
\begin{picture}(1,1)
\linethickness{%
\ifx#1\displaystyle 1.2\fontdimen8\textfont3\else
\ifx#1\textstyle 1.1\fontdimen8\textfont3\else
\ifx#1\scriptstyle1\fontdimen8\scriptfont3\else
1\fontdimen8\scriptscriptfont3\fi\fi\fi
}%
#2
\end{picture}%
}
\newcommand{\my@plus}{%
\roundcap
\Line(0.5,0)(0.5,1)
\Line(0,0.5)(1,0.5)
}
\newcommand{\my@times}{%
\roundcap
\Line(0,0)(1,1)
\Line(0,1)(1,0)
}
\newcommand{\my@narrowtimes}{%
\roundcap
\Line(0,0)(0.75,1)
\Line(0,1)(0.75,0)
}
\newcommand{\my@narrowbox}{%
%\roundcap
\Line(0,0)(0.75,0)
\Line(0.75,0)(0.75,1)
\Line(0.75,1)(0,1)
\Line(0,1)(0,0)
}
\newcommand{\my@narrowmakebig}[2]{%
\vcenter{%
\sbox\z@{$\m@th#1\sum$}%
\setlength{\unitlength}{0.9\dimexpr\ht\z@+\dp\z@}%
\hbox{\kern0.1\wd\z@\my@narrowdraw{#1}{#2}\kern0.1\wd\z@}%
}%
}
\newcommand{\my@narrowdraw}[2]{%
\begin{picture}(0.75,1)
\linethickness{%
\ifx#1\displaystyle 1.2\fontdimen8\textfont3\else
\ifx#1\textstyle 1.1\fontdimen8\textfont3\else
\ifx#1\scriptstyle1\fontdimen8\scriptfont3\else
1\fontdimen8\scriptscriptfont3\fi\fi\fi
}%
#2
\end{picture}%
}
%% Attempt #1 to try to reshape \bigtimes...
%% ...leaves too much space after \bigtimes
%\newcommand{\my@times}{%
% \roundcap
% \Line(0,0)(0.75,1)
% \Line(0,1)(0.75,0)
%}
%% Attempt #2 to reshape \bigtimes, using \scalebox instead ...
%% ... makes lines too thin and leaves too much space after \bigtmies
%\newcommand{\my@@times}{%
% \roundcap
% \Line(0,0)(1,1)
% \Line(0,1)(1,0)
%}
%\usepackage{graphicx}
%\newcommand{\my@times}{%
% \scalebox{0.85}[1]{\my@@times}%
%}
\makeatother
\begin{document}
In-line $
\bigplus_{i\in I} X_i = \bigtimes_{i\in J} Y_i = \bigbox_{i\in I} X_{i} = \bigcup_{i\in I} Z_{i} = \bigcap_{n\in I} Z_{i}
$ here.
\[
\bigplus_{i\in I} X_i = \bigtimes_{i\in J} Y_i = \bigbox_{i\in I} X_{i}= \bigcup_{i\in I} Z_i = \bigcap_{n\in I} Z_{i}
\]
In-line $
\bigplus_{i=0}^{\infty} X_i = \bigtimes_{i=0}^{\infty} Y_i = \bigbox_{i=0}^{\infty} X_{i} = \bigcup_{i=0}^{\infty} Z_{i} = \bigcap_{n=0}^{\infty} Z_{i}
$ here.
\[
\bigplus_{i=0}^{\infty} X_i = \bigtimes_{i=0}^{\infty} Y_i = \bigbox_{i=0}^{\infty} X_{i} = \bigcup_{i=0}^{\infty} Z_i = \bigcap_{n=0}^{\infty} Z_{i}
\]
\end{document}
答案2
这里的问题只是在 中\my@draw
,您使用的picture
环境的宽度固定为\unitlength
,而不管环境的内容如何picture
。因此,符号picture
的环境\bigtimes
(我猜您预期的宽度为 ,0.85\unitlength
因为\scalebox
中的\my@times
)的宽度仍然为\unitlength
。
可能有很多方法可以解决这个问题,但我认为最简单的方法是将 中的调用放在中\my@draw
,而不是将 的内容放在中。这就是我在以下示例中所做的。\my@makebig
\scalebox
\my@times
\scalebox
\documentclass[fleqn]{article}
\usepackage{amsmath,pict2e}
\usepackage{graphicx}
\usepackage{newtxtext,newtxmath}
\newif\iftimes
\timesfalse
\makeatletter
\newcommand{\my@big}[1]{%
\mathop{\vphantom{\sum}\mathpalette\my@makebig{#1}}\slimits@%
}
\AtBeginDocument{%
\DeclareRobustCommand{\bigplus}{\timesfalse\DOTSB\my@big\my@plus}%
\DeclareRobustCommand{\bigtimes}{\timestrue\DOTSB\my@big\my@times}%
}
\newcommand{\my@makebig}[2]{%
\iftimes
\def\scalefactor{0.85}%
\else
\def\scalefactor{1}%
\fi%
\vcenter{%
\sbox\z@{$\m@th#1\sum$}%
\setlength{\unitlength}{0.9\dimexpr\ht\z@+\dp\z@}%
\hbox{\kern0.1\wd\z@\scalebox{\scalefactor}[1]{\my@draw{#1}{#2}}\kern0.1\wd\z@}%
}%
}
\newcommand{\my@draw}[2]{%
\begin{picture}(1,1)
\linethickness{%
\ifx#1\displaystyle 1.2\fontdimen8\textfont3\else
\ifx#1\textstyle 1.1\fontdimen8\textfont3\else
\ifx#1\scriptstyle1\fontdimen8\scriptfont3\else
1\fontdimen8\scriptscriptfont3\fi\fi\fi
}%
#2
\end{picture}%
}
\newcommand{\my@plus}{%
\roundcap
\Line(0.5,0)(0.5,1)
\Line(0,0.5)(1,0.5)
}
\newcommand{\my@times}{%
\roundcap
\Line(0,0)(1,1)
\Line(0,1)(1,0)
}
\makeatother
\begin{document}
In-line $
\bigplus_{i\in I} X_i = \bigtimes_{j\in J} Y_i = \bigcup_{i\in I} Z_{i} = \bigcap_{n\in I} Z_{i}
$ here.
\[
\bigplus_{i\in I} X_i = \bigtimes_{j\in J} Y_i = \bigcup_{i\in I} Z_i = \bigcap_{n\in I} Z_{i}
\]
In-line $
\bigplus_{i=0}^{\infty} X_i = \bigtimes_{j=0}^{\infty} Y_i = \bigcup_{i=0}^{\infty} Z_{i} = \bigcap_{n=0}^{\infty} Z_{i}
$ here.
\[
\bigplus_{i=0}^{\infty} X_i = \bigtimes_{j=0}^{\infty} Y_i = \bigcup_{i=0}^{\infty} Z_i = \bigcap_{n=0}^{\infty} Z_{i}
\]
\end{document}
我认为最好对和\my@makebig
都使用相同的命令,但我不想通过向 中添加另一个参数来扰乱in的调用。这就是我添加该语句的原因,但我真的不是专家,我想可能有更好的方法来做到这一点。\bigtimes
\bigplus
\mathpalette
\my@big
\my@makebig
\iftimes