Copy link to clipboard
Copied
Hi All,
Can anyone help me to align the selected column cells of table in decimal?
Thank you in advance.
Regards,
Sathya Rani M
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thank you for replying. I need to achive this via indesign javascript. please advice.
~Sathya Rani M
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thanks Jarek for taking care of this. I thought I was in the regular
forum when I answered...
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
@Andreas – And not to forget:
use the right font (OTF) with the right feature for the alignment of digits:
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
Copy link to clipboard
Copied
Good point, Uwe!
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
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
});
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now