首页 > 解决方案 > 如何在 LaTeX 中获得通过将一个字符放在另一个表面上而产生的符号?

问题描述

我需要输入在此处输入图像描述我的文档,但我找不到正确的方法。看起来它是通过某种方式组合$\Diamond$而成的。$\Box$那么我怎样才能得到它呢?

标签: latex

解决方案


如果您在某处找不到可用的符号,我认为使用 tikz 将是一个简单的解决方案。小 tikz 图片可以内联或定义为命令。符号可以创建为重叠节点的内容、节点形状或手工制作的 tikz 路径。以下代码显示了一些示例:

\documentclass{article}%
\usepackage{tikz}%
\usepackage{amssymb}
\usetikzlibrary{shapes,math}

\newcommand{\myawesomesymbol}[1]{\tikz[baseline=-1mm]{\node[diamond, draw, inner sep=#1]{}; \node[draw, inner sep=#1]{};}}
\newcommand{\mythicksymbol}[1]{\tikz[baseline=-1mm]{\node[thick, diamond, draw, inner sep=#1]{}; \node[thick, draw, inner sep=#1]{};}}

\newcommand{\myhandmadesymbol}[1]{\tikz[baseline=-1mm]{ 
\draw[] (-#1,-#1) -- (#1,-#1) -- (#1,#1) -- (-#1,#1) -- (-#1,-#1); 
\draw[] (-2.1*#1, 0) -- (0,2.1*#1) -- (2.1*#1,0) -- (0, -2.1*#1)-- (-2.1*#1,0);}}

\begin{document}
This is some sentence with this symbol \tikz[baseline=-1mm]{\node[diamond, draw]{}; \node[draw]{};} in the text. 
This one \myawesomesymbol{.7mm} is smaller and as a command and there is a larger one: \myawesomesymbol{3mm}, or scaling with the font size: {\tiny tiny  \myawesomesymbol{.5ex}}, {\small small \myawesomesymbol{.5ex}}, Large {\Large \myawesomesymbol{.5ex}}. 
Maybe thick: \mythicksymbol{1.5mm}. 
Using tikz, it is also possible to overlay math symbols as suggested in the question: \tikz[baseline=-1mm]{\node[]{\Huge$\diamond$}; \node[]{\tiny$\Box$};}, however, the spacing is not perfect. 
And last, in case the little overlapping corners are a concern, it is still possible drawing it by hand: small \myhandmadesymbol{.1}, larger \myhandmadesymbol{.2}, scaling with font \myhandmadesymbol{.5ex}.
\end{document}

输出:

在此处输入图像描述


推荐阅读