Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the system resource file there is a template:

@@resource PackageTemplate
    RowBox[{"BeginPackage", "[", "\"\<\[Placeholder]`\>\"", "]"}]], "Code"],
    RowBox[{"Begin", "[", "\"\<`Private`\>\"", "]"}]], "Code"],
    RowBox[{"End", "[", "]"}]], "Code"],
    RowBox[{"EndPackage", "[", "]"}]], "Code"]

I suppose there is also an automatic way to insert or use this template. What is it?

share|improve this question
up vote 6 down vote accepted

You can get the template using FrontEndResource:

 (* Notebook[
  {Cell[BoxData[RowBox[{"BeginPackage", "[", "\"\[Placeholder]`\"", "]"}]], "Code"], 
   Cell[BoxData[RowBox[{"Begin", "[", "\"`Private`\"", "]"}]], "Code"],
   Cell[BoxData[RowBox[{"End", "[", "]"}]], "Code"], 
   Cell[BoxData[RowBox[{"EndPackage", "[", "]"}]], "Code"]}] *)

Usage example:


enter image description here

share|improve this answer
I thought I must be missing something; thanks. Is FrontEndResource documented somewhere? – Mr.Wizard Aug 13 '12 at 14:08
@Mr.Wizard, I have not come across anything in the docs; but, as you must have noticed, text resource files have several example uses such as the piece FrontEndExecute[FrontEnd`NotebookPut[FEPrivate`FrontEndResource["FEExpressions"‌​, "SlideshowTemplate"]]] in Finding the right syntax took several "trial-and-crash" attempts. – kglr Aug 13 '12 at 14:35
@Mr.Wizard This is not your first encounter with FrontEndResource. See your answer here. – Sjoerd C. de Vries Aug 13 '12 at 19:59
@Sjoerd More evidence of my failing memory. ::sigh:: – Mr.Wizard Aug 14 '12 at 0:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.