Getting stylized text with a palette button
- To: mathgroup at smc.vnet.net
- Subject: [mg28548] Getting stylized text with a palette button
- From: Raul Martinez <rmartinez at vrinc.com>
- Date: Wed, 25 Apr 2001 19:21:56 -0400 (EDT)
- Organization: Vista Research Inc
- Sender: owner-wri-mathgroup at wolfram.com
To the Group, I would like to define a palette with buttons that produce stylized text in a notebook Text cell. The following is a specific example. While in a Text cell, I want to click a button that produces the symbol x[n] in Times font and with the x and n in italics. So I produced a palette with a single button containing x[n] with the Times font and the desired italics. The results are puzzling. When I click the button while in a Text cell I get x[n] in plain Courier font. But I get the x[n] I want when I click the button while in an Input cell. Changing the Input cell to a Text cell causes x[n] to change from Times/italics to Courier/plain, which is of course the same result I get by starting in a Text cell. Attached is a notebook containing the example and the palette. I will greatly appreciate the Group's help in this matter. Raul Martinez (************** Content-type: application/mathematica ************** Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info at wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 4260, 141]*) (*NotebookOutlinePosition[ 4891, 163]*) (* CellTagsIndexPosition[ 4847, 159]*) (*WindowFrame->Normal*) Notebook[{ Cell["\<\ Select the following cell and create a palette. Then click the \ pallete to get the symbol into the notebook. Below I tried it while in input \ mode and in text mode. The problem is that the symbol shows the way I want it \ in input mode, but not in text mode.\ \>", "Text"], Cell[BoxData[GridBox[{ { ButtonBox[ RowBox[{ StyleBox["x", "Text", FontFamily->"Times", FontWeight->"Plain", FontSlant->"Italic"], StyleBox["[", "Text", FontFamily->"Times", FontWeight->"Plain", FontVariations->{"CompatibilityType"->0}], StyleBox["n", "Text", FontFamily->"Times", FontWeight->"Plain", FontSlant->"Italic"], StyleBox["]", "Text", FontFamily->"Times", FontWeight->"Plain", FontVariations->{"CompatibilityType"->0}]}]], ButtonBox["\[Placeholder]"], ButtonBox["\[Placeholder]"]}, { ButtonBox["\[Placeholder]"], ButtonBox["\[Placeholder]"], ButtonBox["\[Placeholder]"]}, { ButtonBox["\[Placeholder]"], ButtonBox["\[Placeholder]"], ButtonBox["\[Placeholder]"]} }, RowSpacings->0, ColumnSpacings->0, GridDefaultElement:>ButtonBox[ "\\[Placeholder]"]]], "Input"], Cell["\<\ The following shows when I click the palette while in input \ mode\ \>", "Text"], Cell[BoxData[ RowBox[{ StyleBox["x", "Text", FontFamily->"Times", FontWeight->"Plain", FontSlant->"Italic"], StyleBox["[", "Text", FontFamily->"Times", FontWeight->"Plain", FontVariations->{"CompatibilityType"->0}], StyleBox["n", "Text", FontFamily->"Times", FontWeight->"Plain", FontSlant->"Italic"], StyleBox["]", "Text", FontFamily->"Times", FontWeight->"Plain", FontVariations->{"CompatibilityType"->0}]}]], "Input"], Cell["\<\ The following shows when I click the palette while in text \ mode\ \>", "Text"], Cell["\tx[n]", "Text"], Cell[TextData[{ "What I want is to get the text mode symbol look like ", StyleBox["x", FontSlant->"Italic"], "[", StyleBox["n", FontSlant->"Italic"], "], which is the way it looks in input mode." }], "Text"] }, FrontEndVersion->"4.1 for X", ScreenRectangle->{{0, 1280}, {0, 1024}}, WindowSize->{520, 600}, WindowMargins->{{150, Automatic}, {Automatic, 52}} ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[1705, 50, 284, 5, 68, "Text"], Cell[1992, 57, 1244, 37, 81, "Input"], Cell[3239, 96, 90, 3, 32, "Text"], Cell[3332, 101, 579, 21, 27, "Input"], Cell[3914, 124, 89, 3, 32, "Text"], Cell[4006, 129, 22, 0, 32, "Text"], Cell[4031, 131, 225, 8, 50, "Text"] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)