0

I need create a new math symbol a q with a bar just like command \hbar (h with a bar)

Thanks for your help, this is an example

\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}

  • Well, go to this answer and just replace lambda with q. You might want to further fine tune the height to suit q. – AboAmmar Oct 11 '20 at 01:08
  • Avoid commath; I don't see how units helps as you're loading siunitx. Your preamble is full of contradictory calls: why txfonts if you're later loading fourier? And are you sure that fourier math fonts are compatible with Arial as the main text font? – egreg Oct 14 '20 at 21:47

1 Answers1

1

It depends on the math font you're using.

With Computer Modern, taking the cue from https://tex.stackexchange.com/a/551356/4427, but also from the fact that the bar is at a different position, namely \mathchar '26, we can do

\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}

enter image description here

For the fourier math fonts, the code should be modified, because they don't have the required bar in the expected place. I'll solve this by horizontally scaling a minus sign.

\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}

enter image description here

egreg
  • 1,121,712