3
$\begingroup$

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?

$\endgroup$

1 Answer 1

2
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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