# Fractional alignment

So I have this basic code:

But the fractional alignment looks awful, any tips to fix this?

\documentclass[11pt, a4paper]{report}
\usepackage{bm}
\usepackage{amsfonts, graphicx, verbatim, amsmath,amssymb, amsthm, mathrsfs, eufrak}
\usepackage{color}
\usepackage{array}
\usepackage{setspace}% if you must (for double spacing thesis)
\usepackage{fancyhdr}
\usepackage{enumitem}
\usepackage{tikz}
\usepackage{parskip}
\usepackage{lipsum}
\usepackage{floatrow}
\usepackage{commath}
\providecommand{\U}{\protect\rule{.1in}{.1in}}

\begin{document}

Let $h$ be a linear mapping of $V_1$ into $V_2$. Let
$h^0 = \frac{1}{\abs G} \sum_{t\in G} (\rho_t^2)^{-1} h \rho_t^1$
where $\abs G$ is the order of $G$. Then
\begin{enumerate}[label=(\roman*)]
\item If $\rho^1$ and $\rho^2$ are not isomorphic then we have $h^0=0$
\item If $V_1 = V_2$ and $\rho^1 = \rho^2$, $h^0$ is a scalar multiple of the identity, the scalar being $\frac{1}{n} Tr(h)$ where $n = \dim(V_1)$
\end{enumerate}

\end{document}


as you notice, it looks awful.

• I mean, can the |G| be pushed a little to the right? since the vertical "bars" and not aligned with the horizontal fractional line? – Maths Apr 9 '19 at 11:37
• You can always add space to it: \,\abs G. – user156344 Apr 9 '19 at 11:40
• Hmm, I don't think it deserves closure. This is a good question and my solution is only a workaround - it is not 100% centered. Maybe some TeXperts out there will provide a good answer. – user156344 Apr 9 '19 at 11:45
• @JouleV I agree, the question shouldn't be closed. It's definitely a bug (feature?) in commath. – campa Apr 9 '19 at 11:52
• See tex.stackexchange.com/a/135985/4427, if you really want to use commath macros. – egreg Apr 9 '19 at 12:50

The commath package provides a highly questionable implementation of \abs. Don't load this package unless you absolutely have to. (Aside: You do not have to for the example at hand.)

• load the mathtools package instead of the amsmath package. The mathtools package is, for all intents and purposes, a superset of the amsmath package; and

• issue the instruction

\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}


in the preamble. This sets up a proper implementation of \abs{...}. If you need to auto-size the vertical bars, simply use \abs*{...}.

*Addendum": More about how commath implements \envert (\abs is just an alias for \envert): If \envert{<arg>} is invoked without an optional sizing argument (a whole number between 0 and 4), the following code gets executed:

 \!\left\lvert#2\right\rvert


It's the \! ("negative thinspace") instruction that messes up the symmetry of the full expression. Either write \abs{<arg>} to execute \lvert#2\rvert or, more safely, don't load commath at all and go for a cleaner definition of \abs. The definitions of \abs{...} thru \abs{...} are also messed up, by the way, as are the definitions of \norm and \norm thru \norm]4]. While it's possible, in principle, to correct the faulty definitions of \envert, \abs, \enVert, and \norm, one is better off going for a setup that avoids these complications...

• So I should remove the amsath package and insert the mathtools package? would this affect the remaining document consisting of 40-50 pages? if not then I'll change it since you have much more experience. – Maths Apr 9 '19 at 11:58
• @Maths - The mathtools package automatically loads the amsmath package, while taking great care not to mess with the operational details of the macros. – Mico Apr 9 '19 at 12:04

Compare the output of

\documentclass[11pt, a4paper]{report}
\usepackage{amsmath}
\usepackage{enumitem}
\usepackage{commath}

\DeclareMathOperator{\Tr}{Tr}

\begin{document}

Let $h$ be a linear mapping of $V_1$ into $V_2$. Let
$h^0 = \frac{1}{\abs G} \sum_{t\in G} (\rho_t^2)^{-1} h \rho_t^1$
where $\abs G$ is the order of $G$. Then
\begin{enumerate}[label=(\roman*)]
\item If $\rho^1$ and $\rho^2$ are not isomorphic then we have $h^0=0$
\item If $V_1 = V_2$ and $\rho^1 = \rho^2$, $h^0$ is a scalar multiple of the identity,
the scalar being $\frac{1}{n} \Tr(h)$ where $n = \dim(V_1)$
\end{enumerate}

\end{document} with the output of

\documentclass[11pt, a4paper]{report}
\usepackage{amsmath}
\usepackage{enumitem}

\makeatletter
% begin definitions for a "better commath"

\newcommand{\dif}{\mathop{}\!\mathrm{d}}
\newcommand{\Dif}{\mathop{}\!\mathrm{D}}

\newcommand{\spx}{%
\if\relax\detokenize{#1}\relax
\expandafter\@gobble
\else
\expandafter\@firstofone
\fi
{^{#1}}%
}

\newcommand\pd[]{\frac{\partial\spx{#1}#2}{\partial#3\spx{#1}}}
\newcommand\tpd[]{\tfrac{\partial\spx{#1}#2}{\partial#3\spx{#1}}}
\newcommand\dpd[]{\dfrac{\partial\spx{#1}#2}{\partial#3\spx{#1}}}

\newcommand{\md}{\frac{\partial\spx{#2}#1}{\partial#3\spx{#4}\partial#5\spx{#6}}}
\newcommand{\tmd}{\tfrac{\partial\spx{#2}#1}{\partial#3\spx{#4}\partial#5\spx{#6}}}
\newcommand{\dmd}{\dfrac{\partial\spx{#2}#1}{\partial#3\spx{#4}\partial#5\spx{#6}}}

\newcommand{\od}[]{\frac{\dif\spx{#1}#2}{\dif#3\spx{#1}}}
\newcommand{\tod}[]{\tfrac{\dif\spx{#1}#2}{\dif#3\spx{#1}}}
\newcommand{\dod}[]{\dfrac{\dif\spx{#1}#2}{\dif#3\spx{#1}}}

\newcommand{\genericdel}{%
\ifcase#3\relax
\ifx#1.\else#1\fi#4\ifx#2.\else#2\fi\or
\bigl#1#4\bigr#2\or
\Bigl#1#4\Bigr#2\or
\biggl#1#4\biggr#2\or
\Biggl#1#4\Biggr#2\else
\left#1#4\right#2\fi
}
\newcommand{\del}[-1]{\genericdel(){#1}{#2}}
\newcommand{\set}[-1]{\genericdel\{\}{#1}{#2}}
\let\cbr\set
\newcommand{\sbr}[-1]{\genericdel[]{#1}{#2}}
\let\intoo\del
\let\intcc\sbr
\newcommand{\intoc}[-1]{\genericdel(]{#1}{#2}}
\newcommand{\intco}[-1]{\genericdel[){#1}{#2}}
\newcommand{\eval}[-1]{\genericdel.|{#1}{#2}}
\newcommand{\envert}[-1]{\genericdel||{#1}{#2}}
\let\abs\envert
\newcommand{\sVert}{%
\ifcase#1\relax
\rvert\or\bigr|\or\Bigr|\or\biggr|\or\Biggr
\fi
}
\newcommand{\enVert}[-1]{\genericdel\|\|{#1}{#2}}
\let\norm\enVert
\newcommand{\fullfunction}{%
\begin{array}{@{}r@{}r@{}c@{}l@{}}
#1 \colon & #2 & {}\longrightarrow{} & #3 \\
& #4 & {}\longmapsto{}     & #5
\end{array}
}
%%% end of the definitions
\makeatother

\DeclareMathOperator{\Tr}{Tr}

\begin{document}

Let $h$ be a linear mapping of $V_1$ into $V_2$. Let
$h^0 = \frac{1}{\abs G} \sum_{t\in G} (\rho_t^2)^{-1} h \rho_t^1$
where $\abs G$ is the order of $G$. Then
\begin{enumerate}[label=(\roman*)]
\item If $\rho^1$ and $\rho^2$ are not isomorphic then we have $h^0=0$
\item If $V_1 = V_2$ and $\rho^1 = \rho^2$, $h^0$ is a scalar multiple of the identity,
the scalar being $\frac{1}{n} \Tr(h)$ where $n = \dim(V_1)$
\end{enumerate}

\end{document}


The code has already been presented in https://tex.stackexchange.com/a/135985/4427 and provides a full replacement of commath, avoiding all its weaknesses. If you're tied to commath because you use its macros and features in other places, this can save you. Otherwise define \abs with \DeclarePairedDelimiter as suggested by Mico.

For instance, you can notice the reduced space between “where” and “|G|” in the commath version. You should define anyway an operator name for “Tr”.

If you decide to go for this, save the part between

% begin definitions for a "better commath"


and

% end of the definitions


in a file called bettercommath.sty in the working directory and do \usepackage{bettercommath}.