1

The physics package has been instrumental for me in typesetting math cleanly and consistently (while following a lot of nuances of mathematical typesetting). But it does not have integral support. Does anyone know of a package which does? For example, it should add the differential (properly spaced and all) without me having to worry about it. I suppose I can make my own commands, but I was hoping someone already did all the work.

4

Based on the answer of @egreg, I created a similar macro for myself, which also typesets the dx part.

\documentclass[]{article}

\usepackage{xparse}

\newcommand\dd{\mathrm{d}}

\ExplSyntaxOn
\NewDocumentCommand \Int { s o m o }
  {%
    \IfNoValueTF{ #2 }
      { \int }
      {
        \fiziks_int:nn { #1 } { #2 }
      }
    #3
    \IfNoValueF { #4 } { \fiziks_int_dx:n { #4 } }
  }

\seq_new:N \l__fiziks_int_args_seq
\tl_new:N \l__fiziks_int_ast_tl

\cs_new_protected:Npn \fiziks_int:nn #1 #2
  {
    \seq_set_split:Nnn \l__fiziks_int_args_seq { ; } { #2 }
    \seq_map_inline:Nn \l__fiziks_int_args_seq 
      {
        \tl_if_in:nnTF { ##1 } { * }
          {% * case
            \tl_set:Nn \l__fiziks_int_ast_tl { ##1 }
            \tl_remove_once:Nn \l__fiziks_int_ast_tl { * }
            \fiziks_int_inner:NnV \oint { #1 } \l__fiziks_int_ast_tl
          }
          {% no * case
            \fiziks_int_inner:Nnn \int { #1 } { ##1 }
          }
      }
  }
\cs_new_protected:Npn \fiziks_int_inner:Nnn #1 #2 #3
  {
    #1
    \tl_if_blank:nF { #3 } 
      {
        \IfBooleanT { #2 } { \limits }
        \fiziks_int_inner_inner:Nx \sb { \clist_item:nn { #3 } { 1 } }
        \fiziks_int_inner_inner:Nx \sp { \clist_item:nn { #3 } { 2 } }
      }
  }
\cs_generate_variant:Nn \fiziks_int_inner:Nnn { NnV }
\cs_new:Npn \fiziks_int_inner_inner:Nn #1 #2
  {
    \tl_if_blank:nF { #2 } { #1 { #2 } }
  }
\cs_generate_variant:Nn \fiziks_int_inner_inner:Nn { Nx }

\cs_new_protected:Npn \fiziks_int_dx:n #1
  {
    \seq_set_split:Nnn \l__fiziks_int_args_seq { ; } { #1 }
    \seq_map_inline:Nn \l__fiziks_int_args_seq
      {
        \,\dd##1
      }
  }
\ExplSyntaxOff

\begin{document}
\[
  \Int[0,T;0,a]{f^2}[t;x]
  \Int*[0,T;0,a]{f^2}[t;x]
\]
\end{document}

enter image description here

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.