MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Courier New Button, selecting cells without brackets

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50979] Re: [mg50728] Re: Courier New Button, selecting cells without brackets
  • From: "Ingolf Dahl" <ingolf.dahl at telia.com>
  • Date: Thu, 30 Sep 2004 04:52:37 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Thanks for the replies to my questions, but no one seemed to have any font-
change button available. Yes, Jens-Peer, I could make a Palette that sets
the font, thanks for that comment. At the moment I was writing the letter I
just did not see how. I did not see at that special occasion that the
SetOptions command might be used for this purpose. Did you know that? So now
I follow my habit to answer my own questions. Maybe someone will find my
palette useful. It is intended to be used when creating Help files.

Below is a Mathematica command to create a face-and-font change palette. I
have there also included the CopyAsInputForm button, published earlier in
Mathgroup. Due to the structure of Mathematica expressions, the SetOptions
command does not always manage to change options further down in the tree
structure representing the expression, so therefore the buttons will not
work correctly if the expressions are too cluttered. Then it might be
possible to clean up by using the CopyAsInputForm button, and paste back the
expression.

The three font-change buttons change font and slant, but not Bold/Plain or
Underline.

To get the palette, execute the command below. Select the resulting cell,
Use "Generate Palette from Selection" in the File menu. Find your
$BaseDirectory or $UserBaseDirectory. Create a subdirectory
Applications\Palettes\FrontEnd\Palettes there. Close the generated palette
and save it to the file SetFaceAndFont.nb. Then this palette will be
available beneath "Palettes" in the File menu the next time you start
Mathematica.

You might also download the palette directly from
http://w1.318.telia.com/~u31815170/Mathematica/SetFaceAndFont.nb. Save it in
the way described above.

Suggestions to improve this palettes are welcome.
Have Fun!

Ingolf Dahl
Sweden

Mathematica code follows:

NotebookWrite[InputNotebook[],
  Cell[BoxData[{ButtonBox[RowBox[{"Copy", " ", "As", " ", "InputForm"}],
          ButtonFunction :>
            Module[{cpy, cpynb, evalnb},
              CompoundExpression[Set[cpy, NotebookRead[InputNotebook[]]],
                If[SameQ[cpy, {}], Return[]],
                Set[cpynb, NotebookCreate[Visible -> False]],
                NotebookWrite[cpynb, cpy],
                SelectionMove[cpynb, All, Notebook],
                FrontEndExecute[{FrontEndToken[cpynb, "SelectionConvert",
                      "InputForm"]}],
                Set[evalnb,
                  NotebookPut[
                    Notebook[
                      Map[Cell[#, "Input"] &, {BoxData[
                            RowBox[{"cpynb", "=", ToBoxes[cpynb]}]],
                          "FrontEndExecute[{FrontEndToken[cpynb, \
\"CopySpecial\",\"PlainText\"]}]", "NotebookClose[cpynb]",
                          "NotebookClose[EvaluationNotebook[]]"}],
                      Visible -> False]]],
                SelectionMove[evalnb, All, Notebook],
                SelectionEvaluate[evalnb], Null]],
          ButtonEvaluator -> Automatic, Active -> True], "\n",
        RowBox[{StyleBox[
              ButtonBox["Plain",
                ButtonFunction :>
                  SetOptions[NotebookSelection[InputNotebook[]],
                    FontSlant -> "Plain", FontWeight -> "Plain",
                    FontVariations -> {"Underline" -> False}],
                ButtonEvaluator -> Automatic, Active -> True],
              FontFamily -> "Courier", FontSlant -> "Plain"],
            StyleBox[
              ButtonBox["Bold",
                ButtonFunction :>
                  SetOptions[NotebookSelection[InputNotebook[]],
                    FontWeight -> "Bold", Null], ButtonEvaluator ->
Automatic,
                 Active -> True], FontWeight -> "Bold"],
            StyleBox[
              ButtonBox["Italic",
                ButtonFunction :>
                  SetOptions[NotebookSelection[InputNotebook[]],
                    FontSlant -> "Italic"], ButtonEvaluator -> Automatic,
                Active -> True], FontFamily -> "Courier",
              FontSlant -> "Italic"],
            StyleBox[
              ButtonBox["Underline",
                ButtonFunction :>
                  SetOptions[NotebookSelection[InputNotebook[]],
                    FontVariations -> {"Underline" -> True}],
                ButtonEvaluator -> Automatic, Active -> True],
              FontFamily -> "Courier",
              FontVariations -> {"Underline" -> True}]}], "\n",
        RowBox[{ButtonBox[RowBox[{"Courier", " ", "Plain"}],
              ButtonFunction :>
                SetOptions[NotebookSelection[InputNotebook[]],
                  FontSlant -> "Plain", FontFamily -> "Courier"],
              ButtonEvaluator -> Automatic, Active -> True],
            StyleBox[
              ButtonBox[RowBox[{"Times", " ", "Plain"}],
                ButtonFunction :>
                  SetOptions[NotebookSelection[InputNotebook[]],
                    FontSlant -> "Plain", FontFamily -> "Times"],
                ButtonEvaluator -> Automatic, Active -> True],
              FontFamily -> "Times",
              FontVariations -> {"CompatibilityType" -> 0}],
            StyleBox[
              ButtonBox[RowBox[{"Times", " ", "Italic"}],
                ButtonFunction :>
                  SetOptions[NotebookSelection[InputNotebook[]],
                    FontSlant -> "Italic", FontFamily -> "Times"],
                ButtonEvaluator -> Automatic, Active -> True],
              FontFamily -> "Times", FontSlant -> "Italic"]}]}],
    NotebookDefault, PageBreakAbove -> True, FontFamily -> "Courier",
    FontSlant -> "Plain"]]

End of Mathematica code

>-----Original Message-----
>From: Jens-Peer Kuska [mailto:kuska at informatik.uni-leipzig.de]
To: mathgroup at smc.vnet.net
>Sent: Saturday, September 18, 2004 11:48
>To: mathgroup at smc.vnet.net
>Subject: [mg50979] [mg50728] Re: Courier New Button, selecting cells without
>brackets
>
>
>Hi,
>
>you can make a Mathematica palette that set the fonts.
>The HelpBrowser has a ScreenStyle environment to suppress
>the cell-brackets and you should simply switch to this
>environment.
>
>Regards
>  Jens
>
>Berit Dahl wrote:
>>
>> I am trying to write some Help pages, and there I need to be
>able to change
>> some words to the font "Courier New" (Regular) or to "Times New Roman"
>> (Italic). Now I use "Choose Font" under Format, but since I have
>many fonts
>> installed, it is a bit cumbersome. Is there any key sequence
>available, or
>> has anyone a convenient button for these tasks?
>> Another question: In the help files, often there are no cell
>brackets. How
>> can I choose a whole cell without cell brackets? I can choose "Show
>> Expression" beneath Format, and edit the style, but there should be some
>> simpler way.
>>
>> Ingolf Dahl
>> Sweden
>



  • Prev by Date: finding roots tests=MIME_BOUND_NEXTPART,RCVD_IN_ORBS,RCVD_IN_OSIRUSOFT_COM, X_OSIRU_OPEN_RELAY version=2.55
  • Previous by thread: Re: Courier New Button, selecting cells without brackets
  • Next by thread: Statistics`NormalDistribution` doesn't work?