Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to insert a (text) cell into a notebook that replicates the behaviour of tab stops in MS Word, for example. Put differently, I have two strings and I want the one string to align on the left side of a page and the other string to align on the right side of the page but on the same line.

I thought it may perhaps be possible using some version of:

Cell[
    TextData[{
            Cell["First String",TextAlignment->Left], " \t ",
            Cell["Second String",TextAlignment->Right]
    }], "Text"]

Of course, this doesn't work. In fact, I have realised that I can't use regular menu formatting commands to create the effect I want in a cell (so that I could look at the raw expression and see how it is done). Perhaps it can't be done?

However I do know, for example, that one can set the PageFooters/PageHeaders option in the stylesheet for a notebook and that this option is preset to accept a list like {{ll,lc,lr},{rl,rc,rr}} where the first list is for left-facing pages and the second for right-facing pages and the three elements in each list correspond to left alignment, center alignment and right alignment of text in the footer (essentially what I want to do in a regular cell).

Any suggestions?

share|improve this question

1 Answer 1

Maybe this could work for you:

Composition[
  CellPrint,
  Cell[#, "Text"] &,
  BoxData,
  ToBoxes,
  Grid[{{
      Pane[#, Alignment -> Left], 
      Pane[#2, Full, Alignment -> {Right, Center}]}}] &
  ][
    "Left",
    "Right"
   ]

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.