2 column documents in mathematica

风流意气都作罢 提交于 2020-01-01 02:18:08

问题


Mathematica can be used to write very nice documents. Does anyone know if it is possible to write documents with 2 columns? If so, can you provide some examples or links to other notebooks that show this style.


回答1:


I don't think any good implementation of multicolumns are supported in Mathematica - it's not really compatible with the structure of the notebook interface. The fact that publicon does not support proper multiple columns is probably a good hint that Mathematica does not.

Q: Does Publicon support multi-column layout?

Publicon documents are oriented toward a vertical scrolling paradigm much like HTML, rather than a page-by-page configuration found in page-layout programs. Multiple columns can be configured in tables, but not maintained as flows. Publicon's focus is on document structure, allowing clean translation to LaTeX or XML for submission to publishers. Publishers can then use page-layout tools that exploit their own particular formats to generate single- or double-column layouts to their own specifications.

Although, of course, hacks like Bilateral Cells (part of the Author Tools package mentioned in Verbia's answer) and that below can be used.

Here's some code that generates a two column text cell that will resize the columns to the window size - but the text does not flow from one column to another. Once the cell is generated, you can type in it as per normal.

Cell[BoxData[
   GridBox[{{Cell["Column One:\nsome text", "Text"], 
      Cell["Column Two:\nmore text", "Text"]}}, ColumnsEqual -> True, 
    ColumnSpacings -> 2, ColumnAlignments -> Left, 
    ColumnWidths -> Dynamic[First[WindowSize /. Options[EvaluationNotebook[]]]/(2*18)]]], 
  "Text"] // CellPrint

Or you can have text on the left an input/output on the right

Cell[BoxData[GridBox[{
     {Cell["Column One:\nsome text", "Text"], Cell[BoxData[RowBox[{"1", "+", "1"}]], "Input"]},
     {"\[SpanFromAbove]", Cell[BoxData["2"], "Output"]}}, 
    ColumnsEqual -> True, ColumnSpacings -> 2, ColumnAlignments -> Left, 
    ColumnWidths -> Dynamic[First[WindowSize /. Options[EvaluationNotebook[]]]/(2*18)]]], 
  "Text"] // CellPrint

Note that I've only done a dodgy conversion from pixels to em by dividing the former by 18. The true conversion will be system and font dependent. Also, just adding CellLabels to the input and output cells does not work. So the In[n]:= Out[n]= might need to be added manually using a small middle column.

Finally, it should be possible to construct something like the bilateral cell code used by the author tools package that grabs a Text/MathCaption cell followed by an Input and Output cell and combines them into a two-column construction.




回答2:


Graphics and Inset can be used for layouts, for example:-

text = StringTake[ExampleData[{"Text", "Prufrock"}], {226, 931}];
columntext1 = StringTake[text, 350];
columntext2 = StringTake[text, {348, 706}];
column1 = Graphics[{White, Rectangle[{0, 0}, {150, 210}], Black,
    Inset[TextCell[columntext1,
      LineSpacing -> {0, 16}, TextJustification -> 1],
     {0, 210}, {Left, Top}, {150, Automatic}]},
   PlotRange -> {{0, 150}, {0, 210}},
   BaseStyle -> {FontFamily -> "Times", 
         FontWeight -> "Plain", FontSize -> 13}];
column2 = Graphics[{White, Rectangle[{0, 0}, {150, 210}], Black,
    Inset[TextCell[columntext2,
      LineSpacing -> {0, 16}, TextJustification -> 1],
     {0, 210}, {Left, Top}, {150, Automatic}]},
   PlotRange -> {{0, 150}, {0, 210}},
   BaseStyle -> {FontFamily -> "Times", 
         FontWeight -> "Plain", FontSize -> 13}];
image = ExampleData[{"TestImage", "House2"}];
clippedimage = Graphics[{Blue, Rectangle[{0, 0}, {500, 270}],
    Inset[image, {250, 170}, {Center, Center}, {512, 512}]},
   PlotRange -> {{0, 500}, {0, 270}}, ImageSize -> 500];
Graphics[{White, Rectangle[{0, 0}, {330, 400}],
  Inset[column1, {75, 295}, {Center, Center}, {150, 210}],
  Inset[column2, {255, 295}, {Center, Center}, {150, 210}],
  Inset[clippedimage, {165, 90}, {Center, Center}, {330, 179}]},
 PlotRange -> {{0, 330}, {0, 400}}, ImageSize -> 330]




回答3:


This apparently used to be possible using the AuthorTools package for version 5 (see this reference in the Mathematica users wiki).

However, there is no such palette in version 8, and neither the "Writing Assistant" palette nor the Option Inspector seem to have a relevant option.

It might be possible to do something using Grid with text-style Cells inside it, but I doubt it would be straightforward.



来源:https://stackoverflow.com/questions/7135572/2-column-documents-in-mathematica

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!