Skip to content

Instantly share code, notes, and snippets.

@rebcabin
Last active April 14, 2016 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rebcabin/0b9ddf27e1354cbded215594d6f59056 to your computer and use it in GitHub Desktop.
Save rebcabin/0b9ddf27e1354cbded215594d6f59056 to your computer and use it in GitHub Desktop.
Module[{myNotebook, myCells, myStyles, myDemoIntegral, myDemoSolution,
myMathGroup, myItemGroup, myNumberedGroup, myCode, myProgramText,
myMeatyContentGroup, mySectionGroup, myDocumentGroup,
myFontFunction, myDefaultStyles, myNonDefaultStyles},
myDemoIntegral = RowBox[{
RowBox[{"\[Integral]",
RowBox[{"x", RowBox[{"\[DifferentialD]", "x"}]}]}],
"+", SqrtBox["z"]}];
myDemoSolution = RowBox[{
FractionBox[SuperscriptBox["x", "2"], "2"],
"+", SqrtBox["z"]}];
myMathGroup = CellGroupData[{
Cell[BoxData[myDemoIntegral], "Input"],
Cell[BoxData[myDemoSolution], "Output"]},
Open];
myItemGroup = CellGroupData[{
Cell["Item", "Item"],
Cell["ItemParagraph", "ItemParagraph"],
Cell[CellGroupData[{
Cell["Subitem", "Subitem"],
Cell["SubitemParagraph", "SubitemParagraph"],
Cell[CellGroupData[{
Cell["Subsubitem", "Subsubitem"],
Cell["SubsubitemParagraph", "SubsubitemParagraph"]},
Open]]},
Open]]},
Open];
myNumberedGroup = CellGroupData[{
Cell["ItemNumbered", "ItemNumbered"],
Cell["ItemParagraph", "ItemParagraph"],
Cell[CellGroupData[{
Cell["SubitemNumbered", "SubitemNumbered"],
Cell["SubitemParagraph", "SubitemParagraph"],
Cell[CellGroupData[{
Cell["SubsubitemNumbered", "SubsubitemNumbered"],
Cell["SubsubitemParagraph", "SubsubitemParagraph"]},
Open]]},
Open]]},
Open];
myCode = RowBox[{RowBox[{"fun", "[", "x_", "]"}], ":=", "1"}];
myProgramText =
"\<DLLEXPORT int fun(WolframLibraryData libData, mreal A1, mreal \
*Res)
{
mreal R0_0;
mreal R0_1;
R0_0 = A1;
R0_1 = R0_0 * R0_0;
*Res = R0_1;
funStructCompile->WolframLibraryData_cleanUp(libData, 1);
return 0;
}\>";
myMeatyContentGroup = CellGroupData[{
Cell["Subsubsection", "Subsubsection"],
Cell["Text", "Text"],
Cell[myMathGroup],
Cell[myItemGroup],
Cell[myNumberedGroup],
Cell["DisplayFormula", "Text"],
Cell[BoxData[FormBox[myDemoIntegral, TraditionalForm]],
"DisplayFormula"],
Cell[TextData[{
"InlineFormula: ",
Cell[BoxData[FormBox[myDemoSolution, TraditionalForm]]],
"."}],
"Text"],
Cell["NumberedDisplay", "Text"],
Cell[BoxData[FormBox[myDemoIntegral, TraditionalForm]],
"DisplayFormulaNumbered"],
Cell["Code", "Text"],
Cell[BoxData[myCode], "Code"],
Cell["Program", "Text"],
Cell[myProgramText, "Program"]},
Open];
mySectionGroup = CellGroupData[{
Cell["Section", "Section"],
Cell[CellGroupData[{
Cell["Subsection", "Subsection"],
Cell[myMeatyContentGroup]},
Open]]},
Open];
myDocumentGroup = CellGroupData[{
Cell["Title", "Title"],
Cell["Subtitle", "Subtitle"],
Cell["Subsubtitle", "Subsubtitle"],
Cell["Author", "Author"],
Cell["Department", "Department"],
Cell["Date", "Date"],
Cell["Chapter", "Chapter"],
Cell["Subchapter", "Subchapter"],
Cell[mySectionGroup]},
Open];
myCells = {Cell[myDocumentGroup]};
myFontFunction[siz_, fam_: "Candara", wgt_: "Plain",
slt_: "Plain"] := {FontFamily -> fam, FontSize -> siz,
FontWeight -> wgt, FontSlant -> slt};
myDefaultStyles = {
{"Title", 44}, {"Subtitle", 24}, {"Subsubtitle", 16},
{"Author", 14}, {"Department", 11}, {"Date", 11},
{"Chapter", 34}, {"Subchapter", 28},
{"Section", 28}, {"Subsection", 20}, {"Subsubsection", 19},
{"Text", 14},
{"Item", 15}, {"ItemParagraph", 14},
{"Subitem", 13.5}, {"SubitemParagraph", 13.5},
{"Subsubitem", 13}, {"SubsubitemParagraph", 13},
{"ItemNumbered", 15}, {"SubitemNumbered",
13.5}, {"SubsubitemNumbered", 13},
{"DisplayFormula", 14}, {"DisplayFormulaNumbered", 14}};
myNonDefaultStyles = {
{"InlineFormula", 12.6, "Palatino", "Plain"},
{"Code", 12, "Inconsolata", "Bold"},
{"Program", 12, "Courier", "Plain"},
{"Input", 13, "Inconsolata", "Bold"},
{"Output", 13, "Inconsolata", "Plain"}};
myStyles = {
Cell[StyleData[
StyleDefinitions ->
FrontEnd`FileName[{"Report"}, "StandardReport.nb",
CharacterEncoding -> "UTF-8"]]],
Sequence @@ MapThread[
Cell[StyleData[#1], myFontFunction[#2]] &,
Transpose[myDefaultStyles]],
Sequence @@ MapThread[
Cell[StyleData[#1], myFontFunction[#2, #3, #4]] &,
Transpose[myNonDefaultStyles]]};
CreateDocument[
myNotebook = Notebook[
myCells,
StyleDefinitions -> Notebook[
myStyles,
Visible -> False]]]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment