Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

align on decimal in tables

Return to Member Forum

  • Author
    Posts
    • #62973
      fred.lm
      Member

      Hi guys,

      Yes, I have another question :)

      I'm still trying to deal with hundreds of table, and one of the things that highly interests me is the “align on .” feature.

      As it would be fairly tedious to align on the decimal . values for hundreds of table, I'm looking for a script.

      Peter Kahrel proposes one in his book “scripting in indesign cs3/4 with JS”:

      function leftalign_on_unit ()
      {
      var mySelection = app.selection[0];
      if (mySelection.constructor.name != “Cell”) exit ();
      // reset justification and insets
      mySelection.paragraphs.everyItem().justification = Justification.leftJustified;
      mySelection.cells.everyItem().rightInset = 0;
      // get horizontal offset of last insertion point in each cell
      var myArray = mySelection.cells.everyItem().insertionPoints[-1].horizontalOffset;
      // find the biggest value
      longest = max_array (myArray);
      // get position of left side of column
      var myLeftpos = mySelection.cells[0].insertionPoints[0].horizontalOffset;
      // set right column margin (right inset) and justi!cation of selection
      mySelection.rightInset = mySelection.width – (longest – myLeftpos);
      mySelection.paragraphs.everyItem().justification = Justification.rightJustified
      }

      However, nothing happens when I use it in CS6 (no error, no nothing). I guess it's because this script was written for CS3/4, but I can't figure out what's wrong with it and what should be modified to get it work in CS6… any thoughts?

      Thank you very much for your help ;o)

      Fred

    • #62974
      David Blatner
      Keymaster

      Not sure what the script is supposed to do. Does this article help?

      https://creativepro.com/tab…..tables.php

    • #62975
      fred.lm
      Member

      This script is supposed to automatically align on the decimal “.” all numbers in a column.

      The “tab” tool is great (see your link), but not very handy when it comes to 'decimal-aligning' thousands of columns…

    • #63129
      David Blatner
      Keymaster

      I'm sorry, I still don't understand the problem. You can just select the column and apply a align-on-decimal tab stop. Or you can apply it in a paragraph style.

    • #63180
      Chuck Nigash
      Member

      I've done this a lot. Here is the logic: you have a (hard) tab within a Table.

      Steps:

      Create a Para Style that employs the tab on decimal. Best practice > choose centered justification.

      Create a sample Table and make sure you have a tab character in the cells that you want to invoke this aligment.

      Once you tweak that cell as you want it, hit ESC and define the cell, then create a Cell Style.

      Cool would be to search all cells not aligned as you wish, enter a tab character before the number, then apply the cell style.

Viewing 4 reply threads
  • You must be logged in to reply to this topic.
Forum Ads