2

I am trying to get output that would look like this:

enter image description here

The MWE I attached works well for equations with non-nested fractions or without fractions.

The problem arises when I have equations with nested fractions. The text on the left is offset compared to the part of the equation before =. Is there a way to align "Calculation" with "ROIC Ticker" at their baseline?

enter image description here

\documentclass[fleqn, 10pt]{article}

\usepackage{mathtools}

\usepackage{fontspec}
\setmainfont{Source Sans Pro}

\usepackage{unicode-math}
\setmainfont{Asana Math}

\renewcommand{\baselinestretch}{1.25}
\setlength{\mathindent}{0pt}

\usepackage[margin=1in]{geometry}

\begin{document}

\setlength{\abovedisplayskip}{-\baselineskip}
\begin{minipage}[t]{.15\textwidth}
    \textbf{Calculation}\par
\end{minipage}
%
\begin{minipage}[t]{.85\textwidth}
    \begin{align}
        ROIC \ Ticker = \frac{e^{(\sum_{i=1}^{n}{\ln{(1+Daily \ Ticker \ Contribution)}}}-1}{\frac{\sum_{i=1}^{n}|Position \ Size \ (CPS)|}{n}} 
    \end{align}
\end{minipage}

\end{document}
1
  • For better kerning, one should use the italic text font for longer variable names, as the math font can look ugly, here with "T icker" for example (in your first image and in the answers).
    – lblb
    Apr 7, 2018 at 18:49

2 Answers 2

1

1) use \setmathfont{Asana Math}, not \setmainfont.

2) Use alignat rather than two minipages, which align the tops of the minipages, not the top of the first minipage with with the first fraction line of the second minipage.

\documentclass[fleqn, 10pt]{article}

\usepackage{mathtools}

\usepackage{fontspec}
\setmainfont{Source Sans Pro}

\usepackage{unicode-math}
\setmathfont{Asana Math}

\renewcommand{\baselinestretch}{1.25}
\setlength{\mathindent}{0pt}

\usepackage[margin=1in]{geometry}

\begin{document}

    \begin{alignat}{2}
     & \textbf{Calculation} &\qquad \ ROIC \ Ticker & = \frac{e^{(\sum_{i=1}^{n}{\ln{(1+ Daily~Ticker~Contribution)}}}-1}{\frac{\sum_{i=1}^{n}\lvert Position~Size~(CPS)\rvert}{n}}
    \end{alignat}

\end{document} 

enter image description here

5
  • Thank you for the suggestion, the \setmainfont{Asana Math} is more of a typo and me not paying attention to what I copy.
    – b.gegov
    Feb 5, 2017 at 20:40
  • \begin{alignat}{2} & \textbf{Calculation} &\qquad \mathit{ROIC~Ticker} & = \frac{\mathrm{e}^{\,\sum_{i=1}^{n} \ln\left(1+\mathit{Daily~Ticker~Contribution}\right)}-1} {\frac{\sum_{i=1}^{n}\lvert\mathit{Position~Size~(CPS)}\rvert}{n}} \end{alignat} will look better :)
    – Zarko
    Feb 5, 2017 at 20:46
  • @Zarko: Thanks for the suggestion. Actually, I had thought of it, and found no real difference. What I would have liked was \textit, but the default text font is a sans font, so it didn't look very nice. Do you really see a difference in letterspacing with \mathit?
    – Bernard
    Feb 5, 2017 at 21:17
  • Differences are in letter spacing. Many times I have the same dilemma, what is more correct: \textit or mathit. I saw that some experts here prefer latter, i.e.: mathit, since it is name a variable.
    – Zarko
    Feb 5, 2017 at 21:26
  • @Zarko -- it's my understanding that the font used for \mathit is (at least using computer modern) the same as the font for \textit. it is not the same as the italic used for math variables. the reason for the different names is history; plain tex uses \it for both; latex has different ideas about how to do things. Feb 5, 2017 at 23:14
1

Put 'Calculation' inside the environment (which should be equation instead of align in my opinion since you're not aligning anything) without using minipages. AND use \setmathfont instead of \setmainfont for math.

\documentclass[fleqn, 10pt]{article}

\usepackage{mathtools}

\usepackage{fontspec}
\setmainfont{Source Sans Pro}

\usepackage{unicode-math}
\setmathfont{Asana Math}

\renewcommand{\baselinestretch}{1.25}
\setlength{\mathindent}{0pt}

\usepackage[margin=1in]{geometry}

\begin{document}

\setlength{\abovedisplayskip}{-\baselineskip}

\begin{equation}
    \textbf{Calculation}\qquad ROIC \ Ticker = \frac{e^{(\sum_{i=1}^{n}{\ln{(1+Daily \ Ticker \ Contribution)}}}-1}{\frac{\sum_{i=1}^{n}|Position \ Size \ (CPS)|}{n}}
\end{equation}

\end{document} 

enter image description here

1
  • Thank you for the solid answer! I selected Bernard's answer just because it was first, both answers should do the trick for me.
    – b.gegov
    Feb 5, 2017 at 20:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .