Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The following small MWE gives an error, TeX Live 2014

\documentclass[]{article}

\usepackage{amsmath}
\usepackage{physics}    
\let\left\relax
\let\right\relax

\begin{document}    
$\frac{a^2 \left(-\log \left(a^2 \left(\sqrt{\frac{a^2 y(x)}{b^2 x^2}}
  +1\right)-\frac{2 a^2 y(x)}{b x^2}\right)-\frac{2 a 
  \tanh ^{-1}\left(\frac{a^2-4 b \sqrt{\frac{a^2 y(x)}{b^2 x^2}}}
  {a \sqrt{a^2+8 b}}\right)}{\sqrt{a^2+8 b}}\right)}{2 b}=
  \frac{a^2 \log (x)}{b}+c_1,y(x)$    
\end{document} 

When commenting off the physics package it compiles OK!

P.S. I am using the \let\left\relax etc. code to help format long expression when I noticed that it gives an error only when I include the physics package.

pdflatex foo.tex
.......
(/usr/local/texlive/2014/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
! Missing } inserted.
<inserted text> 
                }
l.15   \frac{a^2 \log (x)}{b}
                             +c_1,y(x)$
? 

I have removed the physics package for now. But I am wondering why this happens only with the physics package as I include many other packages without any problem.

share|improve this question
    
You may say \let\left\begingroup and \let\right\endgroup; but the problem is in the autogenerated text, of course. –  egreg Jul 24 at 7:23
2  
You could also load \usepackage[notrig]{physics}, that avoids the redefinitions involvong \left and \right. –  egreg Jul 24 at 7:47

3 Answers 3

up vote 2 down vote accepted

It has something to do with the physics package as you already mention. And it is only

\frac{a^2 \log (x)}{b}+c_1,y(x)  

that is problematic, that is it is actually \log, remove it and the MWE works just fine.

The physics package messes with \log, even after looking at the code, I do not quite understand why.


Update: Physics makes \log(x) have autoscaling fences (not a good idea in general, as we've said may times). It does this with something similar to

\normallog \argopen( x \argclose)

which again is similar to

\normallog \mathopen{}\mathclose\bgroup\left( a \aftergroup\egroup\right)

A \left...\right pair forms a group. So when you let them relax, I'm guessing the \aftergroup will be malplaced giving you the error.

In short, don't do that ;-)

share|improve this answer
    
Why \argclose isn't defined as \def\mathclose#1{\right#1\egroup}? The problem would be disappear. I know that \aftregroup trick is used for cases like \right\delimiter number but this situation doesn't occur in \log argument which is scanned as one-token-left ... one-token-right. –  wipet Jul 24 at 7:22
    
Don't ask me, I didn't write the physics package ;-) Aren't that \mathclose needed to get rid of the extra space inserted by a \left...\right pair? –  daleif Jul 24 at 7:25

I have no problem with an up-to-date TL 2014:

\documentclass[]{article}
\usepackage{mathtools}
\usepackage{physics}    

\begin{document}    
\begin{multline}
 \frac{a^2}{2b} \left(-\log \left(a^2 \left(\sqrt{\frac{a^2 y(x)}{b^2 x^2}}
  +1\right)-\frac{2 a^2 y(x)}{b x^2}\right)-\frac{2 a 
  \tanh ^{-1}\left(\frac{a^2-4 b \sqrt{\frac{a^2 y(x)}{b^2 x^2}}}
  {a \sqrt{a^2+8 b}}\right)}{\sqrt{a^2+8 b}}\right) \\
  = \frac{a^2 \log (x)}{b}+c_1,y(x) 
\end{multline}   
\end{document} 

enter image description here

share|improve this answer
    
I will update TL and try when I get the chance in short time. (this TL was installed about 2 months ago). But you are not using the same MWE code I posted, with those \let commands. Does the same exact code I posted compile ok for you with updated TL? –  Nasser Jul 24 at 6:46
    
no, it doesn't work. physics itself needs the original definitions of \left/\right. –  Herbert Jul 24 at 6:55
    
Thanks, now I understand why it fails then. –  Nasser Jul 24 at 7:01

The physics package implements more intelligence to the macros \log, \sin etc. These macros scan their math parameter and use \left \right primitives at begin of the parameter by very specific way. When you redefine these primitives then these macros collapse, of course. If you need to redefine \left and \right and if you need to use physics package then you can try to add:

\def\log{\mathop{\rm log}\nolimits}
etc.

The question is why you need to use physic package when its intelligence is destroyed by this redefinition.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.