You must add package options to decide via options which part should be loaded.
A list of of nearly every keyval package can you find here:
A big list of every keyval package
An example with kvoptions
is:
\ProvidesPackage{file}
...
\RequirePackage{kvoptions}
\DeclareBoolOption{newcommand}
\DeclareBoolOption{theorem}
\ProcessKeyvalOptions*
....
\iffile@newcommand
\providecommand{\sin}{} \renewcommand{\sin}{\hspace{2pt}\textrm{sen}}
\providecommand{\tan}{} \renewcommand{\tan}{\hspace{2pt}\textrm{tg}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\fi
\iffile@theorem
%use theorem
\usepackage{theorem}
\newtheorem{teo}{Teorema}[section]
\newtheorem{cor}[teo]{Corol\'ario}
\newtheorem{lem}[teo]{Lema}
\newtheorem{prop}[teo]{Proposi\c{c}\~ao}
\fi
...
\endinput
EDIT:
In relation to the comments I present a whole minimal example. To test the different input methods use the commented usepackage
.
\RequirePackage{filecontents}
\begin{filecontents}{mypackage.sty}
\ProvidesPackage{mypackage}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{%
family=MyPack,
prefix=MyPack@,%prefix of all command created by kvoptions
}
\DeclareBoolOption{newcommand}
\DeclareBoolOption{theorem}
\ProcessKeyvalOptions*
\ifMyPack@newcommand
\RequirePackage{amsfonts}
\providecommand{\sin}{} \renewcommand{\sin}{\hspace{2pt}\textrm{sen}}
\providecommand{\tan}{} \renewcommand{\tan}{\hspace{2pt}\textrm{tg}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\fi
\ifMyPack@theorem
%use theorem
\usepackage{theorem}
\newtheorem{teo}{Teorema}[section]
\newtheorem{cor}[teo]{Corol\'ario}
\newtheorem{lem}[teo]{Lema}
\newtheorem{prop}[teo]{Proposi\c{c}\~ao}
\fi
\endinput
\end{filecontents}
\documentclass{article}
\usepackage{mypackage}
%\usepackage[newcommand]{mypackage}
%\usepackage[newcommand=true]{mypackage}
\usepackage{blindtext}
\begin{document}
\ifdefined\Q
defined
\else
not defined
\fi
\end{document}
.sty
. Wouldn't it just be better to copy the contents you're after into a newmyfile.sty
and use\usepackage{myfile}
instead?