Group Abstract Group Abstract

Message Boards Message Boards

[WSG21] Daily Study Groups featuring Notebooks: Intro and Going Further

On October 18th we will begin our next Daily Study Group series that will focus on "Notebooks". As a cohort of online learners we will work through the Wolfram U interactive course "Introduction to Notebooks" in short sessions hosted by Wolfram-certified instructors, that will feature live Q&A, review exercises, and additional examples on topics covered in the course. This study group will help you achieve the "Course Completion" certificate for the "Introduction to Notebooks" course after you complete the course quizzes.

We will follow up the two weeks of the "Introduction to Notebooks" study group with a week-long study group on "Going Further with Notebooks" which will feature additional material that builds on the introductory course. A certificate of program completion will be available for this series as well.

Please sign up here:

We will continue discussion on the topics covered in these study groups on this thread. Looking forward to the questions and shared ideas about using notebooks.

85 Replies

Requesting our study group attendees to kindly refrain from sharing any links emailed to you (notebooks/videos/quizzes) here on the public forum. Thank you.

Posted 4 years ago

The correct answer to Problem 6 in this quiz seems incorrect to me, or at least the wording in the answers is quite ambiguous. Without giving away the answer, consider

Module[{x}, x]
POSTED BY: Rohit Namjoshi

Let me add the following to the question "Using the Module command causes the variable to:"--the "variable" refers to the local variable declared in the Module.

Your options are:

  • (A) The local variable will be assigned a new, random value each time the program is run
  • (B) The local variable will be evaluated again every time any cell in the notebook is evaluated
  • (C) The local variable will be removed from the system after the program (Module) is finished evaluating
  • (D) Both A and B
  • (E) Both B and C
Posted 4 years ago

How soon do we have to submit the solution to the quiz - Going Further with Notebooks? Gurbax Singh

POSTED BY: Gurbax Singh

The deadline for the quizzes for both "Introduction to Notebooks" and "Going Further with Notebooks" is Nov 19, 2021.

Hi. I submitted all my quizzes for the previous NB class on time.
Do I have to submit them again?

I rechecked it: there are 6 quizzes; all are accepted.
Please, comment. Thanks. M

Hi Michael, No you do not have to submit again if you have already completed the 6 quizzes from the "Intro to Notebooks" course. You will receive your certificate of completion associated with the course "Introduction to Notebooks".

We are also offering a "Certificate of Program Completion" specifically for the Study Group "Going Further with Notebooks" that we completed last week. For that certification we are requesting that you complete the quiz that was shared with all study group attendees on the last day (Nov 5, 2021) of the study group.

Question from Tom Milac:

I'm trying to identify when I have clicked on the Text "A" displayed on the code below. I assume the light blue background for the character represents the real estate `owned' to by the "A". I'm trying to understand a way - or the best way - to decide when I have clicked on the "A", i.e., the blue background area.

DynamicModule[{}, 
    EventHandler[ 
        MouseAppearance[ 
            Framed[ 
                Pane[ 
                    Graphics[ 
                        {Circle[{0, 0}, 10], 
                        Text[Style["A", FontSize -> Scaled[0.1]], {0, 0}, Background -> LightBlue] }, 
                    PlotRange -> {{-50, 50}, {-50, 50}} ] 
                ], 
                FrameMargins -> 0, 
                ImageMargins -> 0 
               ], 
            "Arrow" ], 
            {"MouseClicked" :> Print[MousePosition["Graphics"]]}]]

My suggestion would be to wrap the EventHandler around the smallest object on which you would like to detect the mouse click.

DynamicModule[{},
 MouseAppearance[
  Framed[
   Pane[
    Graphics[
     {Circle[{0, 0}, 10],
      EventHandler[
       Text[Style["A", FontSize -> Scaled[0.1]], {0, 0}, 
        Background -> LightBlue],
       {"MouseClicked" :> Print[MousePosition["Graphics"]]}
       ]
      },
     PlotRange -> {{-50, 50}, {-50, 50}}]],
   FrameMargins -> 0,
   ImageMargins -> 0],
  "Arrow"]
 ]
Posted 4 years ago

That's very nice. If the question is really "when", then perhaps Print[Now] instead of Print[MousePosition["Graphics"]]?

POSTED BY: Rongoetz
Posted 4 years ago

Michael, Yes, you have to precede your reference with "paclet:" to get a hyperlink to the local help system. See the documentation for Hyperlink: Hyperlink["hyperlink", "paclet:ref/Hyperlink"].

To get a URL for the web documentation, you can click on the dropdown list next to "URL" in the upper right corner of a help page and click "Copy web URL", getting, on the Hyperlink page, for example: http://reference.wolfram.com/language/ref/Hyperlink.html

POSTED BY: Rongoetz

Thank you, rongoetz. Very helpful. M

Posted 4 years ago

Hi Michael, do you mean what is shown in the attachment? (To local reference you need to write the word "paclet:" in front of the link on the reference)

Attachment

POSTED BY: lara wag

And it's a good breathing exercise :)

Thank you, Abrita. You are saying that this is not recommended. But is it possible? Sure, it does not work directly and blocks evaluation. But can we hack it? May be with some version of Hold or anything that prevents evaluation at some step/level. Any advice would be appreciated. M

Hi Michael, If you use the Hyperlink Head on the symbol Framed, it will change the expression into

Hyperlink[Framed, "http://reference.wolfram.com/language/ref/Framed.html"]

This expression has a Head "Hyperlink" now. It cannot work as the symbol Framed anymore.

We do not recommend creating hyperlinks from parts of your code itself. Rather Hyperlink is better used to create buttons or links from pieces text and strings.

Posted 4 years ago

I've been going through the Manipulating Notebooks tutorial (tutorial/ManipulatingNotebooks#31306) and in the very beginning it says that the keyboard shortcut Ctrl+8 can be used to "put up a dialog box to allow input of a cell in Wolfram Language expression form". My system does not respond to this keyboard shortcut. Do I need to change a setting in the Preferences dialog or ...?

Thanks.

POSTED BY: Rongoetz

Hi Ron, The shortcut Ctrl+8 or Ctrl+* is currently assigned to convert an "Input" style cell with Wolfram Language code into an Initialization cell. You will notice it listed as the shortcut key next to Cell -> Cell Properties -> Initialization cell menu item.

I will forward a report to the development team about the text in the documentation at https://reference.wolfram.com/language/tutorial/ManipulatingNotebooks.html that is causing confusion.

"Ctrl+* or Ctrl+8 (between existing cells) put up a dialog box to allow input of a cell in Wolfram Language expression form"

While on the topic of shortcut keys, it should be possible to edit the KeyEventTranslations.tr or MenuSetup.tr file (found at $InstallationDirectory/SystemFiles/FrontEnd/TextResources/<OS>/) to customize your shortcut keys and add new ones. Also, as per the post here another long-term Wolfram user @Rolf Mertig has created a package Shortcuts to allow you to customize shortcuts.

Posted 4 years ago
POSTED BY: Rongoetz

Unfortunately no. My suggestion would be to use CellPrint to quickly see if the Cell looks the way you would like it to in your working notebook itself or use CreateDocument with that cell as its content and view it in a separate notebook.

Posted 4 years ago

Got it. Thanks, Abrita.

POSTED BY: Rongoetz
Posted 4 years ago
POSTED BY: Gerald Dorfman

Right, we can use the Image Assistant toolbar as explained in the documentation for Predictive Interface

enter image description here

Posted 4 years ago

I pasted a screen image into LibreOffice Writer and cropped it. When I pasted the cropped image into a Mathematica text cell, the uncropped image appeared. How can I get just the cropped image to appear? Is there an interactive way to work with images in Mathematica?

POSTED BY: Gerald Dorfman

I did some tests creating notebooks automatically with code and data, here they are:

Create a Wolfram Notebook with Wikipedia Data
https://community.wolfram.com/groups/-/m/t/2398375

Create a Wolfram Notebook from a novel text file
https://community.wolfram.com/groups/-/m/t/2398391

Create Wolfram Notebook from WEB API JSON data
https://community.wolfram.com/groups/-/m/t/2398806

POSTED BY: Daniel Carvalho

Cool examples Daniel. Thanks for sharing.

Thank you, Daniel. M

Daniel, could you please advise what would be an appropriate name for my Roam page with this type of entries? How about "Creating Wolfram notebooks from (?) various data sources"? Thanks. M

Perhaps something more general:

  • Automated Wolfram Notebook Authoring
  • Automated Wolfram Notebook Creation
  • Programmatically create Wolfram Notebooks
POSTED BY: Daniel Carvalho
Posted 4 years ago

What information do the cell brackets convey? It appears to me that the two lines atop signify text, the open triangle an input cell, the open triangle with a line an output cell (?), and a small x with a line below? I find these visual cues helpful. Could you please mention the correct meaning for the ones I mention above, and any others I might have missed? Thank you!

POSTED BY: Heidi Liu
Posted 4 years ago
POSTED BY: Heidi Liu
Posted 4 years ago

From Gurbax Singh I have noticed the following two points: 1. To get the item bullet (the red little square), you can tap Shift+8/, it may give you the bullet or the star as it is supposed to do. However, if your cursor is blinking on the insertion bar and then you tap Shift+8/, you will get the beautiful red bullet every time.

  1. You can insert a different bullet as follows: go to Format->CellDingbat->a popup menu of 28 bullets to choose from shows - square (filled/empty), circle (filled/empty), wolf, diamond, and others. However, they are in black/white.

Question: How can you style it - change its color, etc.

POSTED BY: Gurbax Singh

Style the character you want to use for the CellDingbat as you would like:

Style[Framed[\[Wolf], Background -> Black, FrameMargins -> 0], 
 FontSize -> 24, RGBColor[1., 0.5, 0.1`]]

Add it as the CellDingbat option for the cell:

CellPrint[
 Cell["A test subitem", "Text", 
  CellDingbat -> 
   BoxData[
    ToBoxes[
     Style[Framed[\[Wolf], Background -> Black, FrameMargins -> 0], 
      FontSize -> 24, RGBColor[1., 0.5, 0.1`]]]]]]

enter image description here

Posted 4 years ago

Abrita Chakarvarty, John Burgers, Michael Partensky How about this simple-minded way which produces the same output:

Grid[Table[10 i + j, {i, 4}, {j, 8}], Frame -> All, 
 Background -> {{}, {}, {{2, 5} -> Orange}}]

From Gurbax Singh

POSTED BY: Updating Name
Posted 4 years ago

If I recall correctly, in today's session someone asked about formatting typeset equations over multiple lines, where each line is aligned to the equals sign.

I tried looking for clear answers for a while and couldn't find anything that would apply to DisplayFormula or DisplayFormulaNumbered cells, assuming the goal is to just include typeset math in a notebook (and not just "computable" Input).

A first try was using an Input cell of the form:

enter image description here

where the two equations are entered via inline TeX input (control-4 on macOS). Of course, the result isn't just typeset math as text.

I did find a workaround by creating a DisplayFormula or DisplayFormulaNumbered cell, then using the math notation palettes or keyboard shortcuts to create a one-column, multiline "matrix/array" (without delimiters). I then entered one equation per line. For each equation, I positioned the cursor to just before the equals sign and entered "escape-a-m-escape" to enter alignment markers. After that, I showed the cell expression (shift-command-e on macOS) and modified the GridBoxAlignment option to "=", as shown below. This resulted in the numbered equation (2) shown in the screenshot image below.

enter image description here Note: I duplicated the DisplayFormulaNumbered cell to include both views in the image above.

I would imagine that there's a much better way to do this type of multiline typesetting. So, I offer my less-than-great attempt in the hope that someone else has figured out a more elegant solution or may gain some inspiration to do so.

Cheers,

Dave

POSTED BY: Dave McCollum

To align equations on the "=" sign you can use from the palette Writing Assistant -> Math Cells -> Equal Symbol Aligned Math Cell.

Dave also suggests setting the "Alignment" option to the character "=". Mentioned under "Details" on https://reference.wolfram.com/language/ref/Alignment.html: "c" aligned on the specified character in a grid

    Grid[{
          {x == y1 + y2 + y3}, 
          {a + b + c + d + e == 0}, 
          {1 ==  p + q + r + t + y}}, 
           Alignment -> "\[Equal]"]
Posted 4 years ago

Abrita wrote:

To align equations on the "=" sign you can use from the palette Writing Assistant -> Math Cells -> Equal Symbol Aligned Math Cell.

Aha. Thanks! I thought that there should be some way to align cells using the interactive math palettes/features but couldn't find it...

POSTED BY: Dave McCollum

Thank-you Abrita, I should have been more specific in the lesson chat. In the lesson we created a notebookobject nb=CreateDocument[expr]. It had opened a new notebook in a window on the screen. Then I closed that window (without saving the notebook). My question then was it was still possible to use the variable nb to which the notebook object was assigned, in order to once again show that same window. We tried in the lesson to use NotebookPut[nb] without success. Upon further searching around I gathered that the nb object is indeed a reference, for example

TemplateBox[{"749e6404-fb04-4112-b623-677fe1c7c939", "\"Untitled-13\""}, "NotebookObjectUUIDUnsaved"]

On inspection I would gather this reference disappears once the window was closed unsaved. So the only remedy is to once again run the CreateDocumet[expr] to show the window again.

POSTED BY: John Burgers

Right, if we close a programmatically created notebook without saving it, we will not be able to get back the Notebook object.

Hi Michael, Ah, you've posted yourself to a mental challenge !! The code is concise, and still readable. You did it!! I would not go any further. John

POSTED BY: John Burgers

Thanks, John. Just trying to build a bridge between the current and previous classes. The #s, @s and &s already require refreshment! :) Best. M

Posted 4 years ago

If you want more # @ //.... :-)

g = Grid[#, Frame -> All, Background -> {{}, {}, {{2, 5} -> Orange}}] &;
t = Range[10 # + 1, 10 # + 8] & /@ Range@4;
t // g
POSTED BY: Rohit Namjoshi

Awesome, Rohit! In my view, Range mapping Range is really out of box! And it's very nicely compartmentalized, with elegant "post-processing" (can I put it this way?) . Thank you!

Hats off to you Rohit. Agree with Michael that's awesome. Thanks!

POSTED BY: John Burgers

Good Job, John. I also have a question (not a challenge though, - just curious).
Consider the example from NB09TablesFinal.nb:

Grid[{{11, 12, 13, 14, 15, 16, 17, 18},
  {21, 22, 23, 24, 25, 26, 27, 28},
  {31, 32, 33, 34, 35, 36, 37, 38},
  {41, 42, 43, 44, 45, 46, 47, 48}}, Frame -> All,
 Background -> {{}, {}, {{2, 5} -> Orange}}]

This makes the code shorter:

Grid[Range[#[[1]], #[[2]]] & /@ 
  Table[{10i + 1, 10i + 8}, {i, 1, 4}], Frame -> All, 
 Background -> {{}, {}, {{2, 5} -> Orange}}];

What are the better ways?

Fun challenge for the day: Post the code to create the following Grid enter image description here

Colors used: Yellow, Green, Red, Orange, Purple, Magenta

Thanks for the challenge Abrita,

Here is my interpretation of that image,

Grid[Table[Style["x", Bold, FontSize -> 30], {5}, {7}], 
 Background -> {None, {{Green, Yellow}}, {{2, 3} -> Red, {2, 5} -> 
     Orange, {4, 3} -> Purple, {4, 5} -> Magenta}}, 
 Spacings -> {1, 1}]
POSTED BY: John Burgers
Posted 4 years ago

Just the grid colors:

Grid[Table[X, {5}, {7}], 
 Background -> {{}, {{Green, Yellow}}, {{2, 3} -> Red, {4, 3} -> 
     Purple, {2, 5} -> Orange, {4, 5} -> Magenta}}]

I will review the style later :D

POSTED BY: Luis Phillips
Posted 4 years ago
POSTED BY: lara wag
POSTED BY: John Burgers
Posted 4 years ago

Hello John, this is my solution.

If you analyze my result, you will find some differences to Abrita's problem. For example, the divider on the right side does not have the correct thickness.

Grid[
 Table[
  Style["x", RGBColor[{42, 63, 140}/255.], Bold,
   12], {5}, {7}],
 Background -> {
   {},
   {{Green, Yellow}},
   {
    {2, 3} -> Red,
    {4, 3} -> Purple,
    {2, 5} -> Orange,
    {4, 5} -> Magenta
    }
   },
 Dividers -> {-1 -> Black},
 Spacings -> {
   {0, .5, .5, .5, .5, .5, .5, 0},
   {0, .2, .3, .3, .3, .2}
   }
 ]

By the way - I tried to identify the spacings with this:

Manipulate[
 Grid[
  Table[
   Style["x", RGBColor[{42, 63, 140}/255.], Bold,
    12], {5}, {7}],
  Background -> {{},
    {{Green, Yellow}},
    {
     {2, 3} -> Red,
     {4, 3} -> Purple,
     {2, 5} -> Orange,
     {4, 5} -> Magenta
     }
    },
  Dividers -> {-1 -> Black},
  Spacings -> {
    {h1, h2, h3, h4, h5, h6, h7, h8},
    {v1, v2, v3, v4, v5, v6}
    }
  ],
 "horizontal spaces",
 {{h1, 0}, -1, 4}, {{h2, 0}, -1, 4}, {{h3, 0}, -1, 4}, {{h4, 0}, -1, 
  4}, {{h5, 0}, -1, 4}, {{h6, 0}, -1, 4}, {{h7, 0}, -1, 
  4}, {{h8, 0}, -1, 4},
 Delimiter,
 "vertical spaces",
 {{v1, 0}, -1, 4}, {{v2, 0}, -1, 4}, {{v3, 0}, -1, 4}, {{v4, 0}, -1, 
  4}, {{v5, 0}, -1, 4}, {{v6, 0}, -1, 4}]

It turns out that h8 works, but h1, v1 and v6 do not. It seems that the spacings "before"/"after" an entries only have an effect if there is something before or after - like the delimiter after the last column (h8).

I used the coordinate tool to find the RGB values of the letters - see attached picture.

@Abrita: Could you also tell us what WL commands you used to create the image?

Attachment

Attachments:
POSTED BY: lara wag

Just found the video, but it was suddenly interrupted by the announcement of the forthcoming session. Is there a YouTube version? Thanks.

Attachment

Attachments:
POSTED BY: John Burgers

Thanks for sharing John. Another helpful hammer for the reasonably smaller nails :) is the "clean start" as explained here: https://support.wolfram.com/12464

Posted 4 years ago
POSTED BY: Gerald Dorfman

Hi Gerald, sometimes a restart of Mathematica is required to remove a palette. Also two other places you should check for palette-related notebooks are the Applications folder in BaseDirectory and UserBaseDirectory. If you find files related to your palette in those folders, delete them and restart Mathematica.

To finalize, save and install the palette on your system, could you try the instructions in this tutorial? Let us know if you continue to face issues with using the installed palette.

Interactive Wordcloud

Getting two columns in a notebook

The notebook does not support content in two columns automatically. But you can create a Grid to get it in two columns. Try:

{col1, col2} = 
  StringTakeDrop[ExampleData[{"Text", "DeclarationOfIndependence"}], 
   4500 - 42];
Grid[{{col1, col2}}]

or

Grid[{Style[#, FontFamily -> "Times"] & /@ {col1, col2}}]

Resource of the day: A great video class explaining the Manipulate function: https://www.wolfram.com/wolfram-u/catalog/gen702/

POSTED BY: James Choi

Hi James, Thanks for an excellent question. Unfortunately I do not have an answer for you yet but I have reached out for more information. I'll post on the thread as soon as I have something.

You need to set the "ShowSyntaxStyles" option to True. For example:

SetOptions[EvaluationNotebook[],PrintingStyleEnvironment -> "Printout", ShowSyntaxStyles -> True]
Export[FileNameJoin[{NotebookDirectory[], "ShowSyntaxStylesPrintout.pdf"}], EvaluationNotebook[]];
SystemOpen[%]

Attached is an example notebook and the corresponding PDF.

You found it! Thank you!

I don't mean to sound greedy but is there an option I can set to preserve the syntax coloring when I copy and paste the Wolfram Language statements?

Thank you!

POSTED BY: James Choi

Thank you!

POSTED BY: Steven Zimmerman

A nice post on community about a custom stylesheet: https://community.wolfram.com/groups/-/m/t/2018326

Posted 5 years ago

Are the videos we're viewing in the class sessions available online, other than in the meeting recording?

POSTED BY: Wissam Barakat
Posted 5 years ago

Question of the day: What is one notebook feature that you have found especially useful in your work?

I enjoy the feature that allow inserting code from other programming languages into the notebook. Additionally, the ability to convert notebook cells into LaTeX or the feature that allows inserting inline LaTeX expressions into cells have made mathematical typesetting quick and easy.

As of version 12.3, using the drawing tools is much easier than the previous versions.

POSTED BY: Steven Zimmerman

Folding and unfolding the groups of cells :)

  1. How can I find your saved response to my inquiry in the class?
  2. How do I get a temporary online account? I planned using my home Mathematica, but realized that links to the files in the NB version of a lesson point to the files stored in the cloud.

Thank you, Abrita. Sorry I did not see it before.

Posted 4 years ago

One thing I appreciate about the notebook interface in recent years that might seem trivial to new users is the quick option to "Convert to Text Cell". As someone who has typed a lot of text cells -- while too frequently forgetting to type the Alt+7 shortcut first -- I know the new shortcut has saved me a lot of time since its implementation. There are a lot of little improvements like that that make Mathematica the most usable software system I've ever used.

POSTED BY: Rongoetz
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard