Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Reg. Decimal Alignment in selected column of a Table

Guest
Oct 31, 2013 Oct 31, 2013

Hi All,

Can anyone help me to align the selected column cells of table in decimal?

Thank you in advance.

Regards,

Sathya Rani M

TOPICS
Scripting
3.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Mentor , Oct 31, 2013 Oct 31, 2013

Hi,

As Ariel wrote, in case of table you don't need to type "tabs" inside cells to reach a goal.

Below is an example of last column's setting

var

     mCols = app.activeDocument.textFrames[0].tables[0].columns[-1],

     mTarget = mCols.cells.everyItem().texts.everyItem().getElements(),

     len = mTarget.length;

while (len-->0)

          mTarget[len].tabStops.add({

                    alignment: TabStopAlignment.CHARACTER_ALIGN,

                    alignmentCharacter: ".",

                    position: m

...
Translate
People's Champ ,
Oct 31, 2013 Oct 31, 2013

Select your column. Open the Tabs panel. Add a decimal tab where you

want it and that's it. All the numbers will line up. In a table, you do

not even need to add the actual tab mark before the numbers.

Ariel

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 31, 2013 Oct 31, 2013

Thank you for replying. I need to achive this via indesign javascript. please advice.

~Sathya Rani M

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Oct 31, 2013 Oct 31, 2013

Hi,

As Ariel wrote, in case of table you don't need to type "tabs" inside cells to reach a goal.

Below is an example of last column's setting

var

     mCols = app.activeDocument.textFrames[0].tables[0].columns[-1],

     mTarget = mCols.cells.everyItem().texts.everyItem().getElements(),

     len = mTarget.length;

while (len-->0)

          mTarget[len].tabStops.add({

                    alignment: TabStopAlignment.CHARACTER_ALIGN,

                    alignmentCharacter: ".",

                    position: mCols.width - 10

                    });

Notice: it should work in a simple doc as an example (1 textFrame and 1 table)

Jarek

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Oct 31, 2013 Oct 31, 2013

Thanks Jarek for taking care of this. I thought I was in the regular

forum when I answered...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 01, 2013 Nov 01, 2013

Thank you for replying.

from the provided code, the table cells are not reflecting with dot align.

My exact case is "I need to align selected column cells with dot alignment" .

Please help me.

Kindly excuse if anything found wrong.

~Sathya Rani M

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Nov 01, 2013 Nov 01, 2013

Hi,

If your goal is exact case you need to provide exact source doc or edit applied code according to your local circumstances.

Provided code is an example to illustrate how it works - not a solution for exact case. It should work if run with a new doc - 1 text frame - 1 table inside.

alignmentCharacter: "."     ==> here you can type an alignment char

Jarek

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 01, 2013 Nov 01, 2013

Jarek's script works fine for me. A very good demonstration. You just need to create a test doument and add a single table to it. (It will not work on any given document.) This forum is a place to share and learn, and to get tips on how to make scripts. Often you will not get complete solutions.

Here is an alternate suggestion: you could create a paragraph style with the tabs set as Jarek describes.

Define the alignment character on the tabs tab of the paragraph style dialogue. Then, in your script, just assign that paragraph style to the selection of your document.

There is another thing that is relevant to add: you need to have the the cell contents LEFT aligned. Any other alignment will ruin the "Align to decimal" setting!

On the image below, the text is RIGHT aligned. That is why my text is not paying attention to the Align to decimal setting (that is also assigned).

Capture.PNG

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 01, 2013 Nov 01, 2013

@Andreas – And not to forget:

use the right font (OTF) with the right feature for the alignment of digits:

Table_TabAlignDecimal.png

The same table,  the same  OTF formatting; with two different fonts.

Left column: Contextual (OTF)
Right column: Tabular Lining (OTF)

Of course, you could chose otherwise, if you prefer a stronger reading order from left to right.

Uwe

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 01, 2013 Nov 01, 2013
LATEST

Good point, Uwe!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 01, 2013 Nov 01, 2013

I have a document with one textframe and one table has in it and selected the entire column.

Now I need to align all the selected to dot align. I have tried with the below code snippet. but not getting the output.

Please help me out in this.

var

     //mCols = app.activeDocument.textFrames[0].tables[0].columns[-1],

     mCols = app.selection[0],

     mTarget = mCols.cells.everyItem().texts.everyItem().getElements(),

     len = mTarget.length;

     alert(len);

//while (len-->0)

for(var i=0; i<len; i++)

{

          mTarget.tabStops.add({

                    alignment: TabStopAlignment.CHARACTER_ALIGN,

                    alignmentCharacter: ".",

                    position: mCols.width - 10

                    });

                }

~Sathya Rani M

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 01, 2013 Nov 01, 2013

Why actually do you need a script for this? InDesign aligns numbers on

the decimal point very nicely without a script. Just create a paragraph

style with the appropriate tab settings and apply as needed to your

tables...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 01, 2013 Nov 01, 2013

Thank you for all. At last i found the output as jarek suggested.

Thanks for all once again for spending time on this.

code:

var

     mCols = app.selection[0],

     mTarget = mCols.cells.everyItem().texts.everyItem().getElements(),

     len = mTarget.length;

for(var i=0; i<len; i++)

{

          mTarget.tabStops.add({

                    alignment: TabStopAlignment.CHARACTER_ALIGN,

                    alignmentCharacter: ".",

                    position: mCols.width - 40 // Just adjusted the value

                    });

                }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines