# .sty file in preamble

Suppose I have the following code:

%! xelatex

\documentclass{report}

\usepackage{fontspec}
\usepackage{xltxtra,xgreek}
\setmainfont{Times New Roman}

\usepackage{definitions}
%\newtheorem{prop}{Πρόταση}
\begin{document}
\begin{prop}
Μπλα μπλα μπλα
\end{prop}
\end{document}


definitions is a .sty file where it contains only the command \newtheorem{prop}{Πρόταση}. Now, if I run the code as it is, the output will be just Μπλα μπλα μπλα. However, if I comment the \usepackage{definitions} command and un-comment the \newtheorem{prop}{Πρόταση}, the output is going to be as expected. What am I missing here?

• Did you read the console output? Don't you get complaints about the file? – cfr Oct 7 '15 at 2:53
• Purely a guess, but maybe you have the wrong text encoding in the .sty file? – Mike Renfro Oct 7 '15 at 2:54
• Actually, first error is from Babel. This doesn't compile for me at all. – cfr Oct 7 '15 at 2:55
• "Environment prop undefined. \begin{prop}" is what the console spits out. – thanasissdr Oct 7 '15 at 2:55
• @cfr I use xelatex. – thanasissdr Oct 7 '15 at 2:56

It works fine if you pay attention to the errors and follow Babel's advice:

\begin{filecontents}{definitions.sty}
\newtheorem{prop}{Πρόταση}
\end{filecontents}

\documentclass[greek]{report}

\usepackage{fontspec}
\usepackage{babel}
\setmainfont{Times New Roman}

\usepackage{definitions}
\begin{document}
\begin{prop}
Μπλα μπλα μπλα
\end{prop}
\end{document}


However, your package should also declare itself properly. Minimally something like:

\ProvidesPackage{definitions}
...
\endinput


EDIT Your corrected MWE compiles without error on my system, producing the same output as shown above. While the packages may not be recommended, they do not seem to lead to compilation errors:

\begin{filecontents}{definitions.sty}
\newtheorem{prop}{Πρόταση}
\end{filecontents}

\documentclass{report}

\usepackage{fontspec}
\usepackage{xltxtra,xgreek}% Not recommended: certainly drop xltxtra; consider using babel or polyglossia
\setmainfont{Times New Roman}

\usepackage{definitions}
\begin{document}
\begin{prop}
Μπλα μπλα μπλα
\end{prop}
\end{document}

• While I run it instead of Πρόταση 1 Mπλα μπλα μπλα, the output is ?????? 1 Μπλα μπλα μπλα. How should I modify the .sty file? I used your initial code. – thanasissdr Oct 7 '15 at 3:22
• @thanasissdr That works for me. I can't tell you how to fix it because I can't reproduce the issue. The code I posted produces the output I posted. (Either lot of code.) Check the encoding on the .sty file as jon suggested. And read the console output carefully. Maybe your bold TNR doesn't know Greek? – cfr Oct 7 '15 at 3:26
• I don't know how I can check that. However, I'm going to upvote your answer for your suggestion to use either babel or polyglossia rather than xgreek. Thank you. – thanasissdr Oct 7 '15 at 3:35
• @thanasissdr You can use otfinfo -s <path to font> to see which scripts are supported. – cfr Oct 7 '15 at 15:29
• Οκ, I finally managed it! Again, thank you. – thanasissdr Oct 7 '15 at 18:43