Copiar vínculo al Portapapeles
Copiado
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
Copiar vínculo al Portapapeles
Copiado
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
Copiar vínculo al Portapapeles
Copiado
Thank you for replying. I need to achive this via indesign javascript. please advice.
~Sathya Rani M
Copiar vínculo al Portapapeles
Copiado
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
Copiar vínculo al Portapapeles
Copiado
Thanks Jarek for taking care of this. I thought I was in the regular
forum when I answered...
Copiar vínculo al Portapapeles
Copiado
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
Copiar vínculo al Portapapeles
Copiado
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
Copiar vínculo al Portapapeles
Copiado
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).
Copiar vínculo al Portapapeles
Copiado
@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
Copiar vínculo al Portapapeles
Copiado
Good point, Uwe!
Copiar vínculo al Portapapeles
Copiado
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
Copiar vínculo al Portapapeles
Copiado
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...
Copiar vínculo al Portapapeles
Copiado
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
});
}
Encuentra más inspiración, eventos y recursos en la nueva comunidad de Adobe
Explorar ahora