7

This question has been posted several times but...

I'm looking for a consistent implementation of the evaluation symbol:

  • Evaluation bar as delimeter: <...>|
  • Auto-size to its enclosing expression: \left<...>\right

What I'm not looking for is:

  • Evaluation bar as relation: <...>\mid
  • Manual-size to its enclosing expression: <...>bigg|
  • A whole macro!

Now, the problem is that \rvert does not auto-size, whereas \left. inserts extra spacing.

Perfect would be something of the form \left_ telling latex to enclose the expression here while inserting no delimiter from the left at all, no matter wether visible or invisible.

Do you have an idea how to implement the evaluation bar?
(Not just circumventing the problem!)

As an example consider:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
y(a)&=\frac12 x^2|_a\\
y(a)&=\frac12 x^2\rvert_a\\
y(a)&=\left.\frac12 x^2\right|_a
\end{align}
\end{document}
17
  • '\left.<stuff>\right\rvert_{<more stuff>}`
    – user10274
    Dec 10, 2014 at 21:51
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Dec 10, 2014 at 21:53
  • @MarcvanDongen: That is bad as it does not avoid the missing delimiter but inserts an invisible delimiter. Dec 10, 2014 at 22:01
  • 2
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – cfr
    Dec 10, 2014 at 22:04
  • @Freeze_S I am not sure you understand: it's your duty to make LaTeX aware of the delimiters, not the other way around (unfortunately...).
    – user10274
    Dec 10, 2014 at 22:06

2 Answers 2

3

Here is a macro that does auto scaling, but also allows you to manually specify a size if so desired. You can also specif a prefix for the limits if so desired as in the last example on the first group:

enter image description here

Notes:

  • The manually specified size example as just illustrate the possibilities in the size that you can select. I am not suggesting that all those sizes are appropriate for the given fraction.

Code:

\documentclass{article}

\usepackage{amsmath}
\usepackage{xparse}

% http://tex.stackexchange.com/questions/38868/big-parenthesis-in-an-equation
% http://tex.stackexchange.com/questions/6794/about-big-parenthesis-larger-than-bigg
\makeatletter
    \newcommand{\vast}{\bBigg@{3}}
    \newcommand{\Vast}{\bBigg@{3.5}}
    \newcommand{\vastt}{\bBigg@{4}}
    \newcommand{\Vastt}{\bBigg@{4.5}}
\makeatother


\newcommand{\BracKern}{\kern-\nulldelimiterspace}
\NewDocumentCommand{\Eval}{O{} o m m m}{%
    % #1 = prefix to be added to each limit of evaluation (ex "x=").
    % #2 = optional size specification to be applied (defaults to \left \right pair)
    %          \big \Big \bigg \Bigg \vast \Vast \vastt \Vastt
    %
    % #3 = expression being evaluated
    % #4 = lower limit of evaluation
    % #5 = upper limit of evaluation
    \IfNoValueTF{#2}{%
        \left.\BracKern#3\right\rvert_{#1#4}^{#1#5}%
    }{%
        #3#2\rvert_{#1#4}^{#1#5}%
    }%
}

\usepackage{amsmath}

\begin{document}
\noindent
Automatically sized:
\begin{gather*}
    \Eval{x^2}{0}{5} \quad
    \Eval{\frac{1}{x}}{0}{5} \quad
    \Eval[x=]{\frac{1}{x}}{0}{5} 
\end{gather*}
Manually sized
\begin{gather*}
    \Eval[][\big]{\frac{1}{x}}{0}{5}    \quad
    \Eval[][\Big]{\frac{1}{x}}{0}{5}    \quad
    \Eval[][\bigg]{\frac{1}{x}}{0}{5}   \quad
    \Eval[][\Bigg]{\frac{1}{x}}{0}{5}   \quad
    \Eval[][\vast]{\frac{1}{x}}{0}{5}   \quad
    \Eval[][\Vast]{\frac{1}{x}}{0}{5}   \quad
    \Eval[][\vastt]{\frac{1}{x}}{0}{5}  \quad
    \Eval[][\Vastt]{\frac{1}{x}}{0}{5}
\end{gather*}
\end{document}
3
  • Aaah, but for mathjax? (I'm using it mostly for SE.) Dec 10, 2014 at 23:03
  • @Freeze_S I'm afraid that mathjax is off-topic for this site...
    – cfr
    Dec 10, 2014 at 23:17
  • @Freeze_S if you want to re-implement this solution in MathJax, let me know. Dec 13, 2014 at 14:18
3

An application of the macros in https://tex.stackexchange.com/a/136767/4427

\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}

\ExplSyntaxOn
\DeclareDocumentCommand{\xDeclarePairedDelimiter}{mmmO{}}
 {
  \NewDocumentCommand{#1}{sO{}m}
   {
    \IfBooleanTF{##1}
     {
      \egreg_paired_delimiter_expand:nnnn {#2}{#3}{##3}{#4}
     }
     {
      \egreg_paired_delimiter_fixed:nnnnn {##2}{#2}{#3}{##3}{#4}
     }
   }
 }
\cs_new_protected:Npn \egreg_paired_delimiter_expand:nnnn #1 #2 #3 #4
 {% Fix the spacing issue with \left and \right (D. Arsenau, P. Stephani and H. Oberdiek)
  \mathopen{}
  \mathclose\c_group_begin_token
   \left#1
   \str_if_eq:nnT { . } { #1 } { \kern-\nulldelimiterspace }
   #3
   \group_insert_after:N \c_group_end_token
   \right#2
   \tl_if_empty:nF {#4} { \c_math_subscript_token {#4} }
 }
\cs_new_protected:Npn \egreg_paired_delimiter_fixed:nnnnn #1 #2 #3 #4 #5
 {
  \str_if_eq:nnF {.} { #2 } { \mathopen{#1#2} }
  #4
  \mathclose{#1#3}
  \tl_if_empty:nF {#5} { \c_math_subscript_token {#5} }
 }
\ExplSyntaxOff

%% the final optional argument to \xDeclarePairedDelimiter
%% is a subscript to the right fence
\xDeclarePairedDelimiter{\xeval}{.}{\rvert}[\evaluateat]
\newcommand{\evaluateat}{}
\NewDocumentCommand{\eval}{somm}{%
  \begingroup
  \renewcommand{\evaluateat}{#4}%
  \IfBooleanTF{#1}
    {\xeval*{#3}}
    {\IfNoValueTF{#2}{\xeval{#3}}{\xeval[#2]{#3}}}%
  \endgroup
}


\begin{document}
\begin{align}
y(a)&=\eval{\tfrac{1}{2}x^2}{a}\\
y(a)&=\eval[\Big]{\frac{1}{2}x^2}{a}\\
y(a)&=\eval[\bigg]{\frac{1}{2}x^2}{a}\\
y(a)&=\eval*{\dfrac{1}{2}x^2}{a}
\end{align}
\end{document}

The optional argument to \eval is for choosing manually a size; \eval* is like using \left and \right. The second argument is the point of evaluation.

enter image description here

3
  • Aah, but isn't a macro kind of overshot? Dec 10, 2014 at 23:27
  • 2
    @Freeze_S Why? To the contrary, it guarantees uniformity!
    – egreg
    Dec 10, 2014 at 23:28
  • True, but isn't there a simpler way e.g. sth. like \left_ instead of \left. inserting no delimiter at all? Dec 11, 2014 at 9:43

You must log in to answer this question.

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