Text Formattingmodifying a .sty file

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
juliette
Posts: 75
Joined: Thu Nov 20, 2008 10:15 pm

modifying a .sty file

Post by juliette »

Hello,

MnSymbol.sty allows me to make integrals with fancy symbols inside,
such as \sumint (which is an integral sign with a Sigma embedded in its center)

I want to add some new custom integrals to this package. For example, I would like to have an integral with a Z in its center instead of a Sigma.

I looked at the MnSymbol.sty file in a text editor, but I couldn't figure out how it worked.

What I was thinking of doing was adding the line:

\Decl@Mn@Int\Zint

After the line

\Decl@Mn@Int\sumint\dsumint\tsumint

and then the line:

\Decl@Mn@OpD

after the line:

\Decl@Mn@Op\sum\dsum\tsum


Since those are the only two lines that contain the string '\sum' so I'm assuming those are the only two lines necessary in order to make the integral symbol with the Sigma inside it, and therefore probably the only two lines that need to be added in order for my custom symbol to work.

But I'm not sure if this is the way it works and I don't want to risk having to reinstall MikTex again if I screw it up.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

juliette
Posts: 75
Joined: Thu Nov 20, 2008 10:15 pm

Re: modifying a .sty file

Post by juliette »

Okay I made some changes and saved it as a new file called:

MnSymbolNew.sty

which is in a new folder called MikTeX2.8/tex/latex/MnSymbolNew

But my MikTeX package manager doesn't have MnSymbolNew as a package that can be installed. It just doesn't show up on the list.

How do I get MikTeX to recognize that I've added this package ?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

modifying a .sty file

Post by localghost »

Your modified package will never appear in the MiKTeX Package Manager (MPM) because it has no entry in the MiKTeX database. So the MPM won't recognize it as a package which belongs to the distribution.

Since it is not recommendable to modify a package file you should create your own integral signs by defining a new command. See code below.

Code: Select all

\documentclass[11pt]{article}

\makeatletter
\newcommand{\charint}[1]{\int\kern-1\@ptsize pt #1}
\makeatother

\begin{document}
  \[
    \charint{Z} \charint{A}
  \]
\end{document}

Best regards
Thorsten
juliette
Posts: 75
Joined: Thu Nov 20, 2008 10:15 pm

Re: modifying a .sty file

Post by juliette »

Thanks Thorsten!

That's really neat. Now is there a way to make the Z bigger with respect to the rest of the integral ??

I tried \charint{\scriptsize{Z}} and \charint{\LARGE{Z}} and they were the exact same
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

modifying a .sty file

Post by localghost »

A small modification lets the new command accept an optional argument. But now the characters are upright.

Code: Select all

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

\makeatletter
\newcommand{\charint}[2][\normalsize]{\int\kern-1\@ptsize pt \text{#1#2}}
\makeatother

\begin{document}
  \[
    \charint[\Large]{Z} \charint{A}
  \]
\end{document}
But I'm not sure if it still looks neat because the characters of different size have still the same baseline and don't remain centered horizontally. Perhaps somebody else can offer a more elegant solution.
juliette
Posts: 75
Joined: Thu Nov 20, 2008 10:15 pm

modifying a .sty file

Post by juliette »

Thanks Thorsten,

That actually works quite well!

The last symbol looks just the way I like:

Code: Select all

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

\makeatletter
\newcommand{\charint}[2][\normalsize]{\int\kern-1\@ptsize pt \text{#1#2}}
\makeatother

\begin{document}
  \[
    \charint{n} \charint[\LARGE]{n} \charint[\LARGE]{\em{n}} \charint[\LARGE]{\hspace{-2.4mm} \em{n}} 
  \]
\end{document}

But unfortunately none of this works with when documentclass is revtex4 :cry:

Do you think there's any way to trick revtex4 into letting me use this ??
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

modifying a .sty file

Post by gmedina »

juliette wrote: ...Do you think there's any way to trick revtex4 into letting me use this ?
Even though it's not a perfect solution, perhaps the following could be useful. The \nint command defined below uses the \mathchoice TeX primitive to produce the appropriate symbol (an integral symbol crossed by an "n") according to the fourth basic math styles. Of course, some adjustments will be necessary if the font size for the document is not 11pt. Feel free to adapt my example according to your needs.

Code: Select all

\documentclass[11pt]{revtex4}
\usepackage{amsmath}

\newcommand\nint{\int\mathchoice%
  {\mkern-20mu\fontsize{16}{19}\selectfont\textit{n}}
  {\mkern-15mu\raisebox{1.2pt}{\fontsize{11}{13}\selectfont\textit{n}}}
  {\mkern-14.5mu\raisebox{.8pt}{\fontsize{8}{10}\selectfont\textit{n}}}
  {\mkern-14mu\raisebox{.5pt}{\fontsize{6}{7}\selectfont\textit{n}}}}

\begin{document}

\[ \nint \]

$\nint$

$_{\nint}$

$_{_{\nint}}$

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply