2

I need some new symbols and I don't have any idea how to create them. I tried to find out if these symbols were already in a LaTeX package but they weren't. So finally I ask here.

Every answer will be very helpful for me because I am a novice with using TeX.

The commands I want are going to be used in math mode. I want three commands, but two of them are just variants of the other called \lrod{ }. The name comes from the dowsing tool 'L-rod', grabbed by left hand.

  1. \lrod{ }. The bar whose left tip bent down perpendicularly. See the image below.
  2. \rrod{ }. The right-side version of \lrod{ }.
  3. \stapler{ }. The both-side version of \lrod{ }.

\lrod{ } takes as an argument a letter or a string of letters. Then it gives us the (string of) letter(s) covered by the 'lefthand L-rod' of the appropriate horizontal length above it. That is, if I type

$\lrod{a}$, $\lrod{abc}$ and $\lrod{a \vphantom b},

then I should get the following: /The example of lrod

As you can see, the top height shoud be different for each letter. But if I use \vphantom, then I should be able to fix it.

Additionally, I wish I could trim on my own the length of each segment of your \lrod: the long vertical segment and the short horizontal one. So please don't give me an answer using pdf image, but using the codes only.

The \rrod{ } and \stapler{ } commands can be described in the similar way. Here's an example image.

symbols-example

As you see, the top height and width of three symbols shoud be equal for the same letter.

Finally, the widths of the symbols have to be slightly narrow than the letter below, so that they allow gaps between themselves when I type, say, the following.

$\lrod{b}\rrod{b}\stapler{b}$

Thanks a lot.

1
  • Welcome to TeX.SE! Can you please make your given code snippet compilable? Then we do not have to guess what you are doing ... – Mensch Nov 11 '20 at 10:12
5

Your \stapler is basically the macro \overbracket defined by mathtools. The package allows also to tweak the width of the rules. The default width is somewhat large, so I make it smaller. I define lrod and \rrod analogously to the definition of \overbracket

\documentclass{article}

\usepackage{mathtools}

\newcommand*{\stapler}[1]{{\overbracket[.4pt][.4\fontdimen5\textfont2]{#1}}}

\makeatletter
\newcommand*{\lrod}[1]{%
   \vbox{\m@th\ialign{##\crcr
          \downbracketend{.4pt}{.4\fontdimen5\textfont2}%
          \leaders \vrule \@height .4pt \@depth \z@ \hfil
        \crcr
          \noalign{\kern .2\fontdimen5\textfont2 \nointerlineskip}%
          $\displaystyle{#1}$%
        \crcr}}%
}

\newcommand*{\rrod}[1]{%
   \vbox{\m@th\ialign{##\crcr
          \leaders \vrule \@height .4pt \@depth \z@ \hfil
          \downbracketend{.4pt}{.4\fontdimen5\textfont2}%
        \crcr
          \noalign{\kern .2\fontdimen5\textfont2 \nointerlineskip}%
          $\displaystyle{#1}$%
        \crcr}}%
}

\makeatother

\begin{document}

$\lrod{a}$
$\lrod{\vphantom{b}a}$
$\lrod{b}$
$\lrod{ab}$
$\lrod{abc}$

\medskip
$\rrod{a}$
$\rrod{\vphantom{b}a}$
$\rrod{b}$
$\rrod{ab}$
$\rrod{abc}$

\medskip
$\stapler{a}$
$\stapler{\vphantom{b}a}$
$\stapler{b}$
$\stapler{ab}$
$\stapler{abc}$

\end{document}

enter image description here

I adopted the parameter in front of \fontdimen5\textfont2 from the mathtools code. You may tweak it to suit your needs.

1
  • The Glyphs look so good. Thank you so much. – Alpaca Parka Nov 11 '20 at 10:11
4

The following provides your symbol by drawing the rules using LaTeX's \rule after measuring the size of the argument using \sbox (inside of \mathpalette to allow subscripts and superscripts).

\documentclass[]{article}

\makeatletter
\newcommand*\stapler@ht{.2ex} % height of the ticks on both ends
\newcommand*\stapler@wd{.1ex} % thickness of the rules
\newcommand*\stapler@dv{.2ex} % padding vertically between argument and symbol
\newcommand*\stapler@di{.2ex} % padding applied on either end of the argument
\newcommand*\stapler@do{.2ex} % padding applied on either end around the symbol
\newsavebox\stapler@box
\newif\ifstapler@left
\newif\ifstapler@right
\newcommand*\@stapler[2]
  {%
    \kern\stapler@do\relax
    \sbox\stapler@box{$#1\kern\stapler@di\relax#2\kern\stapler@di\relax$}%
    \ifstapler@left
      \rule
        [\dimexpr\ht\stapler@box+\stapler@dv]
        {\stapler@wd}
        {\dimexpr\stapler@ht+\stapler@wd/2}%
      \kern-\stapler@wd
    \fi
    \rlap
      {%
        \rule
          [\dimexpr\ht\stapler@box+\stapler@dv+\stapler@ht-\stapler@wd/2]
          {\wd\stapler@box}
          {\stapler@wd}%
      }%
    \usebox\stapler@box
    \ifstapler@right
      \kern-\stapler@wd
      \rule
        [\dimexpr\ht\stapler@box+\stapler@dv]
        {\stapler@wd}
        {\dimexpr\stapler@ht+\stapler@wd/2}%
    \fi
    \kern\stapler@do\relax
  }
\newcommand*\stapler{\stapler@lefttrue\stapler@righttrue\mathpalette\@stapler}
\newcommand*\lrod{\stapler@lefttrue\stapler@rightfalse\mathpalette\@stapler}
\newcommand*\rrod{\stapler@leftfalse\stapler@righttrue\mathpalette\@stapler}
\makeatother

\begin{document}
$\lrod{a}\rrod{b}$

$\lrod{abc}\lrod{\vphantom{abc}a}$

$\lrod{b}\stapler{b}\rrod{b}$

$E^{\lrod{b}\stapler{b}\rrod{b}^{\lrod{a}\stapler{a}\rrod{a}}}$
\end{document}

You can customize the looks of it by changing the definitions of the parameters.

enter image description here

1
  • Thank you very much. By studying your code I will be able to do some symbol-creation myself. – Alpaca Parka Nov 11 '20 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.