3

I want to create a new simple symbol.

Because that symbol will be frequently used in my essay, I hope it can be easily used(also for handwriting). My idea is to add one verticle line on an existing symbol, maybe like this:

enter image description here but I don't know how to realize.

Actually I don't care about the shape of this symbol so other custom symbols are also acceptable, but they should meet following needs:

  1. occupying only one character space

  2. can be written up to three strokes

  3. (not must) looks like a variable(x) instead of a operator(+) or relationship(=)


On a non-issue related note, I am interested in customizing symbols. Any helpful material about it?

1
  • Welcome to TeX.SE! Commented Jul 14, 2024 at 15:57

2 Answers 2

6

The idea here is to superimpose a slightly raised | to the Z.

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\NewDocumentCommand{\Zb}{}{{\mathpalette\Zb@\relax}}
\newcommand{\Zb@}[2]{%
  \begingroup
  \sbox\z@{\raisebox{0.125\height}{$\m@th#1|$}}% the bar to be used twice
  \vphantom{\copy\z@}% this is to correctly set the bounding box
  \ooalign{%
    $\m@th#1 Z$\cr % the Z
    \hidewidth\box\z@\hidewidth\cr % the bar
  }%
  \endgroup
}
\makeatother

\begin{document}

$\Zb$ $X_{\Zb}$

\end{document}

serif

If you replace $\m@th#1 Z$\cr with

$\m@th#1 \mathsf{Z}$\cr

you get

sans serif

A different implementation where the bar is set to a length that depends on the symbol.

This works well for symbols that are supposed to sit on the baseline (see the last example). An optional argument is available in order to set the type of the constructed symbol.

\documentclass{article}
\usepackage{amsmath}
\usepackage{pict2e}

\makeatletter
% to have the bar as wide as fraction lines
\newcommand{\getfontdimen}[3]{% https://tex.stackexchange.com/a/572774/4427
  \fontdimen#1
  \ifx#2\displaystyle\textfont\else
  \ifx#2\textstyle\textfont\else
  \ifx#2\scriptstyle\scriptfont\else
  \scriptscriptfont\fi\fi\fi #3%
}
% the main command
\NewDocumentCommand{\barred}{O{}m}{#1{\mathpalette\barred@{#2}}}
% the internal command
\newcommand{\barred@}[2]{%
  \begingroup
  \sbox\z@{$\m@th#1#2$}% the symbol we want the bar over
  % the bar, 0.3ex longer than the total height of the symbol
  \setlength{\dimen@}{\dimeval{\ht\z@+\dp\z@+0.4\getfontdimen{5}{#1}{2}}}
  \sbox\tw@{%
    \raisebox{\dimeval{-\dp\[email protected]\getfontdimen{5}{#1}{2}}}{%
      \begin{picture}(0,\dimen@)
      \roundcap
      \linethickness{1\getfontdimen{8}{#1}{3}}
      \Line(0,0)(0,\dimen@)
      \end{picture}%
    }%
  }%
  \vphantom{\copy\tw@}% this is to correctly set the bounding box
  \ooalign{%
    \box\z@\cr % the symbol
    \hidewidth\box\tw@\hidewidth\cr % the bar
  }%
  \endgroup
}
\makeatother

\newcommand{\Zb}{\barred{Z}}
\newcommand{\zb}{\barred{\mathsf{z}}}

\begin{document}

$\Zb$ $X_{\Zb}$

$\zb$ $X_{\zb}$

$\barred{g}$ $X_{\barred{g}}$

$a\barred[\mathrel]{<}b$

$a\barred[\mathbin]{\circ}b$ (not good)

\end{document}

New implementation

2
  • Thanks very much. What would I change if I wanted to use a lowercase z instead of an uppercase letter? Perhaps the length of the verticle line also need be changed. Commented Jul 15, 2024 at 4:04
  • 1
    @IgnoreMeaning See edit Commented Jul 15, 2024 at 8:24
3

One character spacing is a bit arbitrary since it depends on the chosen character, font, font size, etc. Here are two renditions of your proposed symbol:

\documentclass{article}

\usepackage[T1]{fontenc}
\newcommand{\symb}{{\color{red}Z\kern-.3em\clap|\kern.3em}}

\usepackage{tikz}
\newcommand{\alt}{\tikz[baseline, semithick, draw=red, line join=bevel]{
    \draw (-2.5pt,7pt) -- (2.3pt,7pt) -- (-2.3pt,0) -- (2.5pt,0);
    \draw (0,9pt) -- (0,-2pt);
}}

\begin{document}

\noindent
a\symb{}a\\
aZa\\
a\alt{}a

\end{document}

two variants of "Z" with vertical bar in the middle and red


Edit: You could also use any of the preexisting symbols defined in LaTeX.

Table of various obscure symbols

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.