Skip to main content
Updated the answer to fit with the syntax of version 0.500
Source Link
Gaussler
  • 12.9k
  • 5
  • 42
  • 113

You run into a problem the moment you want to take e.g. the inverse of a', as a'\inv will yield a double superscript error. This issue annoyed me for many years, and eventually, I created the package SemanTeX to solve this and many other problems. It allows you to type all your math semantically, using keyval syntax, and issues like double superscripts never happen. Here is a code example:

\documentclass{article}

\usepackage{semantex}

\NewVariableClass\MyVar[
    output=\MyVar,
    definekeys=define keys={
        {inv}{ upper=-1 },
    },
]

\NewObject\MyVar\va{a} % this means "variable a"

\begin{document}

$ \va[inv] $, $ \va[prime,inv] $, $ \va[prime,spar,inv] $

\end{document}

enter image description here


Following a request from the comments (not to this answer, but to the original question), I provide a macro \inv taking two optional arguments: an optional *, which adds a prime, and an optional argument, which allows you to raise to a negative power other than -1:

\documentclass{article}

\usepackage{xparse}

\NewDocumentCommand\inv{ s O{1} }
{%
    \IfBooleanTF{#1}%
    {%
        ^{\prime-#2}%
    }%
    {%
        ^{-#2}%
    }%
}

\begin{document}

$ a\inv $, $ a\inv[2] $, $ a\inv* $, $ a\inv*[2] $

\end{document}

enter image description here

You can in principle also use a ' instead of a * by replacing { s O{1} } by { t{'} O{1} }. I did not use this approach, as I don’t really find a\inv' to be an intuitive syntax for a'⁻¹ (the inversion and prime are in the opposite order of how they are printed). But that is entirely a matter of personal taste.

You run into a problem the moment you want to take e.g. the inverse of a', as a'\inv will yield a double superscript error. This issue annoyed me for many years, and eventually, I created the package SemanTeX to solve this and many other problems. It allows you to type all your math semantically, using keyval syntax, and issues like double superscripts never happen. Here is a code example:

\documentclass{article}

\usepackage{semantex}

\NewVariableClass\MyVar[
    output=\MyVar,
    definekeys={
        {inv}{ upper=-1 },
    },
]

\NewObject\MyVar\va{a} % this means "variable a"

\begin{document}

$ \va[inv] $, $ \va[prime,inv] $, $ \va[prime,spar,inv] $

\end{document}

enter image description here


Following a request from the comments (not to this answer, but to the original question), I provide a macro \inv taking two optional arguments: an optional *, which adds a prime, and an optional argument, which allows you to raise to a negative power other than -1:

\documentclass{article}

\usepackage{xparse}

\NewDocumentCommand\inv{ s O{1} }
{%
    \IfBooleanTF{#1}%
    {%
        ^{\prime-#2}%
    }%
    {%
        ^{-#2}%
    }%
}

\begin{document}

$ a\inv $, $ a\inv[2] $, $ a\inv* $, $ a\inv*[2] $

\end{document}

enter image description here

You can in principle also use a ' instead of a * by replacing { s O{1} } by { t{'} O{1} }. I did not use this approach, as I don’t really find a\inv' to be an intuitive syntax for a'⁻¹ (the inversion and prime are in the opposite order of how they are printed). But that is entirely a matter of personal taste.

You run into a problem the moment you want to take e.g. the inverse of a', as a'\inv will yield a double superscript error. This issue annoyed me for many years, and eventually, I created the package SemanTeX to solve this and many other problems. It allows you to type all your math semantically, using keyval syntax, and issues like double superscripts never happen. Here is a code example:

\documentclass{article}

\usepackage{semantex}

\NewVariableClass\MyVar[
    output=\MyVar,
    define keys={
        {inv}{ upper=-1 },
    },
]

\NewObject\MyVar\va{a} % this means "variable a"

\begin{document}

$ \va[inv] $, $ \va[prime,inv] $, $ \va[prime,spar,inv] $

\end{document}

enter image description here


Following a request from the comments (not to this answer, but to the original question), I provide a macro \inv taking two optional arguments: an optional *, which adds a prime, and an optional argument, which allows you to raise to a negative power other than -1:

\documentclass{article}

\usepackage{xparse}

\NewDocumentCommand\inv{ s O{1} }
{%
    \IfBooleanTF{#1}%
    {%
        ^{\prime-#2}%
    }%
    {%
        ^{-#2}%
    }%
}

\begin{document}

$ a\inv $, $ a\inv[2] $, $ a\inv* $, $ a\inv*[2] $

\end{document}

enter image description here

You can in principle also use a ' instead of a * by replacing { s O{1} } by { t{'} O{1} }. I did not use this approach, as I don’t really find a\inv' to be an intuitive syntax for a'⁻¹ (the inversion and prime are in the opposite order of how they are printed). But that is entirely a matter of personal taste.

deleted 4 characters in body
Source Link
Gaussler
  • 12.9k
  • 5
  • 42
  • 113

You run into a problem the moment you want to take e.g. the inverse of a', as a'\inv will yield a double superscript error. This issue annoyed me for many years, and eventually, I created the package SemanTeX to solve this and many other problems. It allows you to type all your math semantically, using keyval syntax, and issues like double superscripts never happen. Here is a code example:

\documentclass{article}

\usepackage{semantex}

\NewVariableClass\MyVar[
    output=\MyVar,
    definekeys={
        {inv}{ upper=-1 },
    },
]

\NewObject\MyVar\va{a} % this means "variable a"

\begin{document}

$ \va[inv] $, $ \va[prime,inv] $, $ \va[prime,spar,inv] $

\end{document}

enter image description here


Following a request from the comments (not to this answer, but to the original question), I provide a macro \inv taking two optional arguments: an optional *, which adds a prime, and an optional argument, which allows you to raise to a negative power other than -1:

\documentclass{article}

\usepackage{xparse}

\DeclareDocumentCommand\inv\NewDocumentCommand\inv{ s O{1} }
{%
    \IfBooleanTF{#1}%
    {%
        ^{\prime-#2}%
    }%
    {%
        ^{-#2}%
    }%
}

\begin{document}

$ a\inv $, $ a\inv[2] $, $ a\inv* $, $ a\inv*[2] $

\end{document}

enter image description here

You can in principle also use a ' instead of a * by replacing { s O{1} } by { t{'} O{1} }. I did not use this approach, as I don’t really find a\inv' to be an intuitive syntax for a'⁻¹ (the inversion and prime are in the opposite order of how they are printed). But that is entirely a matter of personal taste.

You run into a problem the moment you want to take e.g. the inverse of a', as a'\inv will yield a double superscript error. This issue annoyed me for many years, and eventually, I created the package SemanTeX to solve this and many other problems. It allows you to type all your math semantically, using keyval syntax, and issues like double superscripts never happen. Here is a code example:

\documentclass{article}

\usepackage{semantex}

\NewVariableClass\MyVar[
    output=\MyVar,
    definekeys={
        {inv}{ upper=-1 },
    },
]

\NewObject\MyVar\va{a} % this means "variable a"

\begin{document}

$ \va[inv] $, $ \va[prime,inv] $, $ \va[prime,spar,inv] $

\end{document}

enter image description here


Following a request from the comments (not to this answer, but to the original question), I provide a macro \inv taking two optional arguments: an optional *, which adds a prime, and an optional argument, which allows you to raise to a negative power other than -1:

\documentclass{article}

\usepackage{xparse}

\DeclareDocumentCommand\inv{ s O{1} }
{%
    \IfBooleanTF{#1}%
    {%
        ^{\prime-#2}%
    }%
    {%
        ^{-#2}%
    }%
}

\begin{document}

$ a\inv $, $ a\inv[2] $, $ a\inv* $, $ a\inv*[2] $

\end{document}

enter image description here

You can in principle also use a ' instead of a * by replacing { s O{1} } by { t{'} O{1} }. I did not use this approach, as I don’t really find a\inv' to be an intuitive syntax for a'⁻¹ (the inversion and prime are in the opposite order of how they are printed). But that is entirely a matter of personal taste.

You run into a problem the moment you want to take e.g. the inverse of a', as a'\inv will yield a double superscript error. This issue annoyed me for many years, and eventually, I created the package SemanTeX to solve this and many other problems. It allows you to type all your math semantically, using keyval syntax, and issues like double superscripts never happen. Here is a code example:

\documentclass{article}

\usepackage{semantex}

\NewVariableClass\MyVar[
    output=\MyVar,
    definekeys={
        {inv}{ upper=-1 },
    },
]

\NewObject\MyVar\va{a} % this means "variable a"

\begin{document}

$ \va[inv] $, $ \va[prime,inv] $, $ \va[prime,spar,inv] $

\end{document}

enter image description here


Following a request from the comments (not to this answer, but to the original question), I provide a macro \inv taking two optional arguments: an optional *, which adds a prime, and an optional argument, which allows you to raise to a negative power other than -1:

\documentclass{article}

\usepackage{xparse}

\NewDocumentCommand\inv{ s O{1} }
{%
    \IfBooleanTF{#1}%
    {%
        ^{\prime-#2}%
    }%
    {%
        ^{-#2}%
    }%
}

\begin{document}

$ a\inv $, $ a\inv[2] $, $ a\inv* $, $ a\inv*[2] $

\end{document}

enter image description here

You can in principle also use a ' instead of a * by replacing { s O{1} } by { t{'} O{1} }. I did not use this approach, as I don’t really find a\inv' to be an intuitive syntax for a'⁻¹ (the inversion and prime are in the opposite order of how they are printed). But that is entirely a matter of personal taste.

added 1034 characters in body
Source Link
Gaussler
  • 12.9k
  • 5
  • 42
  • 113

You run into a problem the moment you want to take e.g. the inverse of a', as a'\inv will yield a double superscript error. This issue annoyed me for many years, and eventually, I created the package SemanTeX to solve this and many other problems. It allows you to type all your math semantically, using keyval syntax, and issues like double superscripts never happen. Here is a code example:

\documentclass{article}

\usepackage{semantex}

\NewVariableClass\MyVar[
    output=\MyVar,
    definekeys={
        {inv}{ upper=-1 },
    },
]

\NewObject\MyVar\va{a} % this means "variable a"

\begin{document}

$ \va[inv] $, $ \va[prime,inv] $, $ \va[prime,spar,inv] $

\end{document}

enter image description here


Following a request from the comments (not to this answer, but to the original question), I provide a macro \inv taking two optional arguments: an optional *, which adds a prime, and an optional argument, which allows you to raise to a negative power other than -1:

\documentclass{article}

\usepackage{xparse}

\DeclareDocumentCommand\inv{ s O{1} }
{%
    \IfBooleanTF{#1}%
    {%
        ^{\prime-#2}%
    }%
    {%
        ^{-#2}%
    }%
}

\begin{document}

$ a\inv $, $ a\inv[2] $, $ a\inv* $, $ a\inv*[2] $

\end{document}

enter image description here

You can in principle also use a ' instead of a * by replacing { s O{1} } by { t{'} O{1} }. I did not use this approach, as I don’t really find a\inv' to be an intuitive syntax for a'⁻¹ (the inversion and prime are in the opposite order of how they are printed). But that is entirely a matter of personal taste.

You run into a problem the moment you want to take e.g. the inverse of a', as a'\inv will yield a double superscript error. This issue annoyed me for many years, and eventually, I created the package SemanTeX to solve this and many other problems. It allows you to type all your math semantically, using keyval syntax, and issues like double superscripts never happen. Here is a code example:

\documentclass{article}

\usepackage{semantex}

\NewVariableClass\MyVar[
    output=\MyVar,
    definekeys={
        {inv}{ upper=-1 },
    },
]

\NewObject\MyVar\va{a} % this means "variable a"

\begin{document}

$ \va[inv] $, $ \va[prime,inv] $, $ \va[prime,spar,inv] $

\end{document}

enter image description here

You run into a problem the moment you want to take e.g. the inverse of a', as a'\inv will yield a double superscript error. This issue annoyed me for many years, and eventually, I created the package SemanTeX to solve this and many other problems. It allows you to type all your math semantically, using keyval syntax, and issues like double superscripts never happen. Here is a code example:

\documentclass{article}

\usepackage{semantex}

\NewVariableClass\MyVar[
    output=\MyVar,
    definekeys={
        {inv}{ upper=-1 },
    },
]

\NewObject\MyVar\va{a} % this means "variable a"

\begin{document}

$ \va[inv] $, $ \va[prime,inv] $, $ \va[prime,spar,inv] $

\end{document}

enter image description here


Following a request from the comments (not to this answer, but to the original question), I provide a macro \inv taking two optional arguments: an optional *, which adds a prime, and an optional argument, which allows you to raise to a negative power other than -1:

\documentclass{article}

\usepackage{xparse}

\DeclareDocumentCommand\inv{ s O{1} }
{%
    \IfBooleanTF{#1}%
    {%
        ^{\prime-#2}%
    }%
    {%
        ^{-#2}%
    }%
}

\begin{document}

$ a\inv $, $ a\inv[2] $, $ a\inv* $, $ a\inv*[2] $

\end{document}

enter image description here

You can in principle also use a ' instead of a * by replacing { s O{1} } by { t{'} O{1} }. I did not use this approach, as I don’t really find a\inv' to be an intuitive syntax for a'⁻¹ (the inversion and prime are in the opposite order of how they are printed). But that is entirely a matter of personal taste.

added 25 characters in body
Source Link
Gaussler
  • 12.9k
  • 5
  • 42
  • 113
Loading
Source Link
Gaussler
  • 12.9k
  • 5
  • 42
  • 113
Loading