Math & ScienceNeed a macro for little oh

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

Need a macro for little oh

Post by Singularity »

Hi. Can someone recommend a good macro for "little oh" (and maybe "big Oh", too)?

I have this in my preamble

Code: Select all

\newcommand{\bigO}[1]{\ensuremath{\mathop{}\mathopen{}\mathcal{O}\mathopen{}\left(#1\right)}}
\newcommand{\littleo}[1]{\ensuremath{\mathop{}\mathopen{}\mathcal{o}\mathopen{}\left(#1\right)}}
"Big Oh" is working fine. But "little oh" is strange. I tried changing "little oh" to

Code: Select all

\DeclareFontFamily{OT1}{pzc}{}
\DeclareFontShape{OT1}{pzc}{m}{it}{<-> s * [1.10] pzcmi7t}{}
\DeclareMathAlphabet{\mathpzc}{OT1}{pzc}{m}{it}
\newcommand{\littleo}[1]{\ensuremath{\mathop{}\mathopen{}\mathpzc{o}\mathopen{}\left(#1\right)}}
Please recommend a good macro for "little oh" (and whatever you use for "big Oh", too, maybe).

Recommended reading 2024:

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

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

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Need a macro for little oh

Post by Johannes_B »

Something like you defined for Oh is already defined by package
physics. No need to trouble yourself.

The output for the little oh is somehow expected, since there is
no lowercase mathcal alphabet.

Code: Select all

% arara: lualatex
\documentclass{article}
\usepackage{stix}
\usepackage{fontspec}
\usepackage{mathtools}
\usepackage{physics}
\begin{document}
\[ 
	\order{x} \quad
	\order{\frac{1}{\frac{1}{2}}} \quad
	\order{\strut} \quad
\]
\[
\mathscr{o} \quad
\mathfrak{o}
\]
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

Need a macro for little oh

Post by Singularity »

writeLaTeX gives the error "! LaTeX Error: File `stix.sty' not found." I got the same error in my home implementation.

This article suggests that I can download stix.sty from this site (use the green button to get a zip file). But I cannot figure out what to do from there, so I have not been able to make your suggestion work.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Need a macro for little oh

Post by Johannes_B »

Try installing it with your package manager.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

Need a macro for little oh

Post by Singularity »

Johannes_B wrote:Try installing it with your package manager.
OK. I'm using Miktex 2.9. I found the Packaga Manager and installed stix. Now it tells me I can't use package fontspec with "pdflatex". I think it's referring to the build's output profile (in TeXnicCenter). And package physics is giving me 20 warnings, too (which seems unusual, since it seems to be a pretty common package).
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Need a macro for little oh

Post by Johannes_B »

You can safely ignore the warnings given by physics. Have a look at the documentation to see why those commands are redefined.

Yes, you cannot use fontspec with pdflatex. I am aware of that, that's why the first line contains the »LuaLaTeX«. Another possibility would be XeLaTeX. If you have to stick with pdflatex, you can comment out package fontspec and load fontenc with your appropriate option instead.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

Need a macro for little oh

Post by Singularity »

OK. Thanks for all your work.

I am not familiar at all with what the build profiles do, but I do see one called XeLaTeX => PDF. I used and it managed to get the symbols for Order and order (big and little O). But can that font be turned on and off? I ask because it is messing with the fonts in the rest of the document.

Here is an MWE. But first, note that I have a somewhat reasonable solution in my OP. I don't want to take up more of your time than this is worth to you. I thought there might be a standard symbol for them.

Code: Select all

\documentclass[fleqn,reqno]{article}
%fleqn: left align equations		
%reqno: equation numbers on right
\usepackage{amsfonts,amsmath,amssymb,amsthm}

\newtheorem{thm}{Theorem}
\newtheorem{define}{Definition}

% ``imaginary'' unit, i, and Euler's (or natural log) e
\newcommand{\I}{\mathrm{i}}
\newcommand{\E}{\mathrm{e}}

% Set notation
%\newcommand{\set}[1]{\left\{{#1}\right\}}
%\newcommand{\setof}[2]{\left\{{#1}\colon{#2}\right\}}

% For big-Oh notation
\usepackage{stix}
\usepackage{fontspec}
\usepackage{mathtools}
\usepackage{physics}

% I think this loads font family mathpzc, used to create the symbol for independence number.
\DeclareFontFamily{OT1}{pzc}{}
\DeclareFontShape{OT1}{pzc}{m}{it}{<-> s * [1.10] pzcmi7t}{}
\DeclareMathAlphabet{\mathpzc}{OT1}{pzc}{m}{it}

% Independence number and complete bi-partite graph.
\newcommand{\indieNum}[3]{\mathpzc{i}_#1 \left( #2; #3 \right)}
\newcommand{\kay}{K_{r,r}}

\begin{document}
$$ 
        \order{x} \quad
        \order{\frac{1}{\frac{1}{2}}} \quad
        \order{\strut} \quad
$$
$$
\mathscr{o} \quad
\mathfrak{o}
$$

\begin{thm}
$\forall c \in \left( -\infty, 1 \right)$ and $G \in \mathcal{G}_{\mathbb{N},r,r}$
\begin{equation*}
	\indieNum{t}{G; \mu} = 
		\begin{cases}
			\left( 1 + \order{\mu^{-\left(1+c\right)}} \right) \indieNum{t}{\kay}{\mu} & $G$ \text{ contains a triangle} \\
			\left( 1 + \order{\mu^{-\left(2+c\right)}} \right) \indieNum{t}{\kay}{\mu} & $G$ \text{ is triangle free}.
		\end{cases}
\label{eq:Result}
\end{equation*}
Furthermore $\indieNum{t}{G}{\mu} \leq \indieNum{t}{\kay}{\mu}$ for infinitely many $\mu \in \mathbb{R}^+$.
\end{thm}


$\order{x^2}$

\end{document}
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Need a macro for little oh

Post by Johannes_B »

I can't tell anything about the math there. I can only sense
that the topic is related to
big O
notation
and related, the little o notation. This is not my
field of expertise, so i am lost.
The original problem was a misleading character for the lower
case calligraphic letters, which do not exist.
Package physices provides the command order. We
already know that by now. My first thought was using something not looking
the same lilke a standard o (small letter oh). Package
stix provides a script and a fraktur alphabet. But
stix is not your only choice. There are many others. Please have
a look at the LaTeX Font Catalogue (especially the
fonts with math support).

This has nothing to do with using xelatex or lualatex, it was
just a suggestion. LuaLaTeX will (in a while) supersede pdflatex,
that was my view of the future.

Having copied and modified (quite unaware of its contents) the
definition of order from package physics, all
remaining is the question of »What font do you want to use«.
Having a look at the wikipedia entry above, they just used the
normal math alphabet.

You can run the following with pdflatex, just as usual. Try
clicking on »open in writelatex« just above the code. I made some
comments, they might be helpful for you (or not) or help you to
understand my train of thought.

Code: Select all

\documentclass{article}
%Stix provides some math alphabets, also script and 
%fraktur (gothic) ones
%\usepackage{stix}
%It is stated in the documentation of STIX that it should be
%loaded before amsmath
\usepackage{amsfonts,amsmath,amssymb,amsthm}
\usepackage{mathtools}%pathces some amsmath quircks
\newtheorem{thm}{Theorem}

\usepackage{physics}
%the following taken, but modified, from physics.sty
\ProvideDocumentCommand\littleordersymbol{}{o} 
%\RenewDocumentCommand\littleordersymbol{}{{\mathsf o}} 
%you set evreything there
\DeclareDocumentCommand\littleorder{ l m
}{\fbraces#1{\lparen}{\rparen}{\littleordersymbol}{#2}} 

%this switches alphabets to palatino
\DeclareFontFamily{OT1}{pzc}{}
\DeclareFontShape{OT1}{pzc}{m}{it}{<-> s * [1.10] pzcmi7t}{}
\DeclareMathAlphabet{\mathpzc}{OT1}{pzc}{m}{it}

\newcommand{\indieNum}[3]{\mathpzc{i}_#1 \left( #2; #3 \right)}
%now using the regular i
\newcommand{\indieNumB}[3]{i_#1 \left( #2; #3 \right)}
\newcommand{\kay}{K_{r,r}}

\newcommand{\littleoh}[1]{\ensuremath{\mathop{}\mathopen{}\mathpzc{o}\mathopen{}\left(#1\right)}}
\begin{document}
\begin{gather*}
%	\indieNum{t}{G; \mu}  \\
	%you did this (^) once, please check
	%Your definition, using palatino i
	\indieNum{t}{G}{\mu}  \\
	%using regular i
	\indieNumB{t}{G}{\mu}  \\
\end{gather*}



%please be aware, that using $$ math $$ is not recommendend
%with LaTeX. It's the old TeX syntax
%\[
%	\mathscr{o} \quad
%	\mathfrak{o}
%\] %commented out, provided by stix

\begin{thm}
	$\forall c \in \left( -\infty, 1 \right)$ and $G \in \mathcal{G}_{\mathbb{N},r,r}$
	\begin{equation*}
		\indieNum{t}{G; \mu} =
		\begin{cases}
			\left( 1 + \order{\mu^{-\left(1+c\right)}} \right) \indieNum{t}{\kay}{\mu} & 
			$G$ \text{ contains a triangle} \\
			%you were already in math mode for the G there,
			%please see the next line
			\left( 1 + \order{\mu^{-\left(2+c\right)}} \right) \indieNum{t}{\kay}{\mu} & G \text{ is triangle free}.
		\end{cases}
		\label{eq:Result}
	\end{equation*}
	Furthermore $\indieNum{t}{G}{\mu} \leq \indieNum{t}{\kay}{\mu}$ for infinitely many $\mu \in \mathbb{R}^+$.
\end{thm}

\begin{gather*} 
o(x)\\
\littleorder{x}\\
% ^ both o letters are the same
\littleoh{x} \\
%this was using the palatino o
\end{gather*}
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply