我需要创建一个带有竖线的新数学符号 aq,就像命令 \hbar (带有竖线的 h)一样
谢谢你的帮助,这是一个例子
\documentclass[]{article}
\usepackage{polyglossia}
\setmainlanguage{spanish}
\usepackage[dvipsnames,svgnames,x11names,]{xcolor}
\usepackage{graphicx}
\usepackage{amsmath,mathtools,calculator}
\usepackage{commath}
\usepackage{xfrac}
\usepackage{fancybox}
\usepackage{multicol}
\usepackage{nicefrac}% UNIDADES SI
\usepackage{units}% UNIDADES SI
\usepackage{pgf,tikz,tikz-3dplot}
\usepackage{pgfplots}
\usepackage[american]{circuitikz}
\usetikzlibrary{arrows,patterns}
\usetikzlibrary{decorations.text,bending}
\usepgfplotslibrary{fillbetween}
\usepgfplotslibrary{groupplots,polar} %
\usepgflibrary{arrows.meta}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{decorations.text}
\usepgfplotslibrary{fillbetween}
\usepgfplotslibrary{groupplots,polar}
\usepackage{cancel}
\usepackage{wasysym}
\usepackage{txfonts}
\usepackage{smartdiagram}
\usepackage{siunitx}
\usepackage{fourier} % math font
\usepackage{fontspec}
%\defaultfontfeatures{Mapping=tex-text}
\setmainfont{Arial}
\begin{document}
This is the document
$\left(x+a\right)^2$, I need a $q$ command with bar
\end{document}
答案1
这取决于您使用的数学字体。
借助 Computer Modern,https://tex.stackexchange.com/a/551356/4427,而且由于杆处于不同的位置,即\mathchar '26
我们可以做到
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand{\addbar@}[2]{%
\makebox[0pt][l]{%
\raisebox{#1}[0pt][0pt]{%
\kern#2
$\m@th\mathchar'26$%
}%
}%
}
\DeclareRobustCommand{\qbar}{\text{\addbar@{-1.5ex}{0.01em}}q}
\makeatother
\begin{document}
Normal size $q\ne \qbar$ and subscript $X_{q}\ne X_{\qbar}$
\end{document}
对于fourier
数学字体,代码应该修改,因为它们在预期的位置没有所需的条。我将通过水平缩放减号来解决这个问题。
\documentclass{article}
\usepackage{amsmath}
\usepackage{fourier}
\usepackage{graphicx}
\makeatletter
\newcommand{\addbar@}[3]{%
\makebox[0pt][l]{%
\raisebox{#1}[0pt][0pt]{%
\kern#2
\scalebox{0.6}[1]{$\m@th-$}%
}%
}%
}
\DeclareRobustCommand{\qbar}{\text{\addbar@{-0.8ex}{0.2em}{1}}q}
\makeatother
\begin{document}
Normal size $q\ne \qbar$ and subscript $X_{q}\ne X_{\qbar}$
\end{document}