2

I have two objects I need to clearly identify in my equations, tilde and bar as operators on variables. However, these are barely legible and not really differentiable, in particular if they appear in the denominator of a fraction.

I'd like to keep referring to the variables as \tilde and \bar in my text, and not introduce a new command. If this implies "too much" space for the bars and tildes outside of fractions, I'm happy to take that cost.

Is there something I can do in the preamble to make these more legible?

% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = pdflatexmk


\documentclass[11pt]{article}
\usepackage{geometry}                % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper}                   % ... or a4paper or a5paper or ... 
\usepackage{dcolumn}
\usepackage{booktabs}
%\usepackage[parfill]{parskip}    % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{amsmath}

\newcommand{\mbeq}{\overset{!}{=}}

\usepackage{epstopdf}
\usepackage[utf8]{inputenc}
\usepackage{marginnote}
\renewcommand*{\marginfont}{\color{red}\sffamily}
\usepackage[backgroundcolor=green, linecolor=green]{todonotes}


\usepackage{placeins}
\usepackage{filecontents}
\usepackage{amsthm}


\usepackage[round]{natbib}
\usepackage[notref]{showkeys}  
\bibliographystyle{chicago}
\newcommand\numberthis{\addtocounter{equation}{1}\tag{\theequation}}

\renewcommand{\topfraction}{0.85}
\renewcommand{\textfraction}{0.1}
\renewcommand{\floatpagefraction}{0.85}
\renewcommand\thesubsection{\thesection.\alph{subsection}}

\usepackage[
      colorlinks=true,    %no frame around URL
      urlcolor=black,    %no colors
      menucolor=black,    %no colors
      linkcolor=black,    %no colors
      citecolor=black,
      bookmarks=true,    %tree-like TOC
      bookmarksopen=true,    %expanded when starting
      hyperfootnotes=false,    %no referencing of footnotes, does not compile
      pdfpagemode=UseOutlines    %show the bookmarks when starting the pdf viewer
]{hyperref}
 \urlstyle{same}



\date{}

\begin{document}


\begin{align*}
\bar p_x &=\begin{cases} a^\frac{1}{\bar\theta} & i < \gamma \\
a^\frac{1}{\tilde\theta} & i \geq \gamma \\
\end{cases}
\end{align*}


\end{document}

enter image description here

  • It could be informative to include also the result that you get from the example file. – mickep Jan 6 '18 at 18:38
  • @mickep I thought that was universal given the latex code - and I can't upload a pdf here it appears.. – FooBar Jan 6 '18 at 18:46
  • 1
    Well, you are correct it will most likely show the same here. But what you then ask for people is to first copy your code, and compile. Instead of just looking at your output and suggesting a solution. You can convert your output to png and upload. (I suggest this in all well meaning, just for you to increase the chance that someone takes a look.) – mickep Jan 6 '18 at 18:48
3

I assume the bar over the \theta in the denominator is the problem. Some variations:

\documentclass[11pt]{article}
\usepackage{amssymb}
\usepackage{amsmath}

\begin{document}
\begin{align*}
  \bar p_x & =
  \begin{cases}
    a^\frac{1}{\bar\theta} & i < \gamma \\
    a^\frac{1}{\tilde\theta} & i \geq \gamma \\
  \end{cases}\\
  \bar p_x & =
  \begin{cases}
    a^{1/\bar\theta} & i < \gamma \\
    a^{1/\tilde\theta} & i \geq \gamma \\
  \end{cases}\\
  \bar p_x & =
  \begin{cases}
    a^{\bar\theta^{-1}} & i < \gamma \\
    a^{\tilde\theta^{-1}} & i \geq \gamma \\
  \end{cases}\\
  \bar p_x & =
  \begin{cases}
    a^\frac{1}{
      \vbox{\kern.2ex\hbox{$\scriptscriptstyle\bar\theta$}}
    } & i < \gamma \\
    a^\frac{1}{\tilde\theta} & i \geq \gamma \\
  \end{cases}
\end{align*}
\end{document}

Result

The latter variation in macro form. \barfix adds a space about the math symbol in the mandatory argument. The optional argument before allows fine-tuning.

\documentclass[11pt]{article}
\usepackage{amssymb}
\usepackage{amsmath}

\makeatletter
\newcommand*{\barfix}[2][.175ex]{%
  \mathpalette{\@barfix{#1}}{#2}%
}
\newcommand*{\@barfix}[3]{%
  % #1: space
  % #2: math style
  % #3: symbol
  \vbox{%
    \kern#1\relax
    \hbox{$#2#3\m@th$}%
  }%
}
\makeatother

\begin{document}
\begin{align*}
  \bar p_x & =
  \begin{cases}
    a^\frac{1}{\barfix{\bar\theta}} & i < \gamma \\
    a^\frac{1}{\barfix[.1ex]{\tilde\theta}} & i \geq \gamma \\
  \end{cases}
\end{align*}
\end{document}

Result

Other macros can be defined on top of \barfix, e.g.:

\newcommand*{\barF}[1]{\barfix{\bar#1}}
\newcommand*{\tildeF}[1]{\barfix[.15ex]{\tilde#1}}
...
$\barF\theta, \tildeF\theta$
  • I like the last version most. Is there any way to redefine \tilde and \bar such that the \barfix{} wrapper is not necessary? – FooBar Jan 6 '18 at 19:09
  • @FooBar There is no easy way. The accents do not know the context, the object above them. If the space is always be set, then it might lead to problems in other contexts (asymmetric line spacing in matrices, ...). LuaTeX allows to traversal the node lists, thus the situations that the accent is too close to a line could be detected. But the programming amount would be huge. – Heiko Oberdiek Jan 6 '18 at 19:49

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.