Table of contents, problems in applying the character style
Hi all
This is my first post, I checked if there was already something similar, but I can't find anything so I'm asking here.
I work with Indesign 9.3 and I created a book of 80 pages and there are 20 + chapters.
I wanted to create a table of contents, so I made an and I put my paragraph for her style, but I had problems to set the character style (he set only to the number of the page, but not to the number and the name of the chapter).
When I create my summary style I have no problem to indicate the paragraph style that you want to use (and then it automatically applies it properly when I generate my list).
The problem I want to solve, is that I need that my table of contents automatically the value of the character style, cause, for the moment, I have to apply it after its generation.
Sorry for my bad English, I hope you understood
Concerning
Filippo
In this case you must use the character for numers style nested within the paragraph style
I'm usually two independent sparagraph styles (primary materials) chapters and sections (toc details). In this way, you can add a different same nested character style to stand them.
Addibn later - style, it is not good idea. After the update of the table of contents, you have lost the
macpawel
Tags: InDesign
Similar Questions
-
Selection of parts and columns, or entire lines and apply the character style
I am trying to apply character styles to certain parts/whole rows and columns.
I can change individual cells with the following code...
table = app.selection[0]; if (table.hasOwnProperty("baseline")) table = table.parent; if (table instanceof Cell) table = table.parent; if (table instanceof Column) table = table.parent; if (table instanceof Row) table = table.parent; if (table instanceof Table) { table.rows[0].cells[6].texts[0].appliedCharacterStyle = "none report"; }
... but when I try to select an entire line, I get the error 'Object does not support property or method' texts. "" "When I try one of the following two codes.
{ table.rows[0].cells.texts.appliedCharacterStyle = "none report"; }
{ table.rows[0].cells.appliedCharacterStyle = "none report"; }
Anyone know how I can do the following?
1. Select any row (or column) and apply the character style
2. Select the last line (regardless of the number of rows in the table) and apply the character style
3. apply the character style to specific columns (with theexception of the cells of two albums)
Thank you!
Hello
Change this line:
table.columns[a].cells.itemByRange(2,-1).texts.everyItem().appliedCharacterStyle = "chart orange";
for the first 2 rows in each column
Jarek
-
How to write the script to apply the character style?
Hello
I'm on a Macbook pro and without a numeric keypad, so I can't assign a shortcut to character styles. I heard a roundabout solution where you can assign a shortcut to a script that applies the character styles. Can anyone write this script?
My character style is called "features"bold. "
I am new to scripting, sorry if this is a stupid question.
See you soon
Hello
1. save this code as a file inside your Script Panel folder .jsx
2. apply a shortcut using the menu Edit: shortcuts...
Option to choose:
- suggest you choose an option 'background': 'Text', so you can use several shortcuts that are occupied in other contexts.
#target indesign if (app.selection && app.selection[0].hasOwnProperty ("baselineShift") ) { var cName = "Features bold"; var mCstyle = app.activeDocument.characterStyles.item(cName); if (mCstyle.isValid) app.selection[0].applyCharacterStyle(mCstyle); else alert ("CharStyle: " + cName + " not found"); } else alert ("Some text supposed to be selected...");
Jarek
-
Apply the character style to the part of the paragraph
I am inserting text in a block of text with the following code:
story.insertionPoints [-1] .silence += pgfStr;
story.insertionPoints [-1] .silence += "\t";
story.insertionPoints [-1] .silence += refStr;
story.insertionPoints [-1] .silence += "\r";
I want to apply the character style to all of the text in refStr (only the part of this paragraph). I know how the syling paragraph applies to the entire paragraph, but not a character style. I should be grateful if you would help. Thank you!
Hello
Dan - BTP says:
... the size in points and attack can be different on each page...
You are able to find a rule of these differences?
...
What do depends on what type of rule could be defined
...
The size of reference point that is 1.5 PT lower than the point size of the paragraph, whatever.
Close to the end of the script, you can code for example:
// Your target is "reference" which is a text inbetween tabulator and end of story (or other criteria). // So you could define: app.findGrepPreferences = null; // just for clear it app.findGrepPreferences.findWhat = "(?<=\\t).+\\s\\Z"; // to catch text following tab in last para of story // and after: mFound = app.activeDocument.findGrep(); // so all desired text objects are in an array "mFound". // you could iterate (backward) through it: len = mFound.length; while (len-->0) // ">0" in case of nothing found mFound[len].pointSize -= 1.5; // whatever that is - is 1.5 smaller
Jarek
-
How to apply the character style to table cell
I'm sure it's basic, but I can't find any references on how to do it and my attempts have failed. I use VB and CS5.5
Basically what I'm trying to do is to select a table cell and apply a character like this style...
MyCharacterStyle = myDocument.CharacterStyles.Add set
myCharacterStyle.Name = "TH2".
myTable2.Cells.Item (1) .appliedCharacterStyle = "TH2".
with this code, I get a "object does not support this property or method. myTable2.Cells.Item (...). appliedCharacterStyle ".
I tried several other versions without success.
Can someone tell me what would be the proper syntax to apply a character style to text in a table cell, or if it's still the right path to follow on that?
I have to select the text in the cell rather than the cell itself, and if so, how do you do that?
Thank you
You do not need to select the text in the cell, but you need
to target rather than the cell. It is true that in the user interface, you can
Select the cell and apply a style of tank, but not with a script. Thus, in
JavaScript is:
myCell.texts.item (0) = .appliedCharacterStyle
app.activeDocument.characterStyles.itemByName ("MyCharStyleName")
It must be something similar in VB also.
Of course, you can target the text in different ways:
myCell.characters.everyItem () or myCell.paragraphs.everyItem () etc etc.
but I think that the text is the most basic of the lot.
Ariel
-
[JS] [CS3] Apply the character Style to the first word
I'm a noob that Javascript is concerned, and I expected a little guidance.
Here is my scenario: I have a book that was composed in a single file; the main content is in a story. I want to select the first word in each block of text on each page and apply a character style. My goal is to use this character style to indicate the page breaks in the XML document - I maps to a specific tag style.
So far, I have this poor specimen:
myDocument var = app.activeDocument;
myPage var = myDocument.pages.item (1);
var myTextFrame = myPage.textFrames.item (0);
If (app.activeDocument.stories [0] .paragraphs [0] .words [0]! = null)
myTextFrame.paragraphs.item (0).words.item (0) = .appliedCharacterStyle
myDocument.characterStyles.item ('foo');I know, I did not implement any kind of loop again (which will be more complicated given that there will be some blank backs, etc.). What I try to do in this is to select the first word in the first paragraph on the second page - which it does in reality. It's the first paragraph of the second begins on the first page, so I select that word on the first page, second page.
As I said, a lot of work to do but a bit of help on getting to the right word would be most appreciated.
Well, you were on the right track, but the "myText" test fails if there is no block of text on a page, because it fails a line earlier
> var myTextFrame = myPage.textFrames.item (0);
just before that, you must test the number of blocks of text:
If (myPage.textFrames.length > 0)
{
... your stuff...
}
Use it only if you are absolutely positive that there is just a block of text on each page! A slightly better way would be to always loop on each textframe:
for (frames = 0; frames
{
var myTextFrame = myPage.textFrames.item (frames);
.. etc.
}in this case you don't have test his first length (the loop will not be executed if there is zero text blocks).
[Grumpy] Since you have only a continuous story, an even better way would be to loop on texts related to this single story executives. You must identify the story somehow, and I usually click on the text cursor in the one that I need:
monarticle = app.selection [0] .parentStory;
or you can rely on the fact that the story begins as part of text on page 1:
monarticle = app.activeDocument.pages [0] .stories [0];
(I think this should work.) Then, each frame of the story until the end can be found in the table
myStory.textContainers
which are usually text blocks. Make a loop on them to help
for (image = 0; frame)
{
myTextFrame = myStory.textContainers [frame];
.. etc.
}
-
Is it possible to add text to the cells and apply the character style in the cell
I work in InDesign on Mac 5.
I have two tables of formatting with information that will be eventually combined. I implemented the scripts I found on these forums to add the columns needed, merge lines and fill the cells merged with the appropriate color, but can't two remaining tasks.
1. is it possible to add text to a cell of some?
2 and it is possible to apply a character style to cells? (different cells than those that I need to add some text)
I played with this code but do not know if it is even close...
{
table. Rows [0]. Cells [0]. InsertText (' CS/PS");
}
{
table. Rows [0]. Cells [0] .appliedCharacterStyle ("bold");
}
Here are the scripts that I have combined so far for the table...
Add column
myTable = app.selection [0];
MyColumn = myTable.columns [1];
for (a = 0; < 1; a ++)
{
myTable.columns.add (LocationOptions.AFTER, myColumn);
}
Merge lines
table = app.selection [0];
If (table.hasOwnProperty ("baseline") table) = table.parent;
If (instanceof cell table) table = table.parent;
If (instanceof column table) table = table.parent;
If (instanceof row table) table = table.parent;
If (instanceof Table table)
{
table. Rows [0]. Cells [0]. Merge (table.rows [0] .cells [1]);
}
{
colours alternating in merged lines
r = table.rows [1];
n = app.activeDocument.swatches.item ("orange");
b = app.activeDocument.swatches.item ("PANTONE 3005 C");
for (c = 0; c < r.cells.length; c ++)
{
If (c & 1)
r.Cells [c]. Properties = {fillColor:b};
on the other
r.Cells [c]. FillColor = n;
}
}
Hello
1. If you want to add the text, go further in:
table. Rows [0]. Cells [0] .insertionPoints [0] .silence = ' CS/PS;
2 similar with application of styles:
table. Rows [0]. Cells [0] .texts [0] .appliedCharacterStyle = "bold" / / If this style is present in your doc
Jarek
-
Apply the character Style to a few characters in a paragraph
Hey,.
Me again - I feel like I'm dumber than a shoe trying to script InDesign
I have a block of text with several paragraphs, which I am adding one by one.
When adding these paragraphs, sometimes I need to apply a character style to some of the characters in the paragraph (I have the clues start and end of these characters to the text of the paragraph).
Using the Guide of the script and the object reference, I cooked up this code below, but not only it doesn't seem to find the character style, she also told me the. itemByRange() is not a function...
What's wrong?
var line_styles = [{ 'start': 22, 'end': 33, 'style': 'Price - SKU' }]; frame.contents += "\r" + line_text; frame.parentStory.paragraphs[-1].applyParagraphStyle(style); for ( var j = 0, k = line_styles.length; j < k; j++ ) { var char_style = doc.characterStyles.item(line_styles[j].style); frame.parentStory.paragraphs[-1].itemByRange( line_styles[j].start, line_styles[j].end ).applyCharacterStyle(char_style, true); }
frame.parentStory.paragraphs[-1].itemByRange(...
does not compute. "paragraphs [-1]" points to a single paragraph and is not an itemByRange method. You must think of sth like
frame.parentStory.paragraphs[-1].characters.itemByRange(...
(Have you used another programming language Javascript front?) A matter of concern for the future: pay attention to your statements 'var '. They do not follow the block scope, as they do in other languages, and therefore persisted in this notation is very likely to bite you back somewhere in the future. Summer, done this, released as well the hair).
-
as the title, I just want to ask how to apply the style of character just for the 1st and 2nd line of the paragraph. Help me pls, tks!
Can you show the screen shot with the invisible market, looks like you feedback after each line.
So, something like this would work where I have a return forced for the linebreak (shift + return). The example on the right does not work because the line break is a return:
-
apply the character style to all get a table row?
Hi chaps (and chapettes)
I have a table - on some lines, I need to change the style of character to "Bold".
How should we do about it in Javascript?
see you soon
Buzz
Have you thought about this?
myRow.cells.everyItem () .texts [0] .appliedCharacterStyle = myChstyle;
Does it work? The difference between this one and your function is that you avoid using the style of the empty cells c., which is not possible with the one-liner above.
Peter
-
Grep help to apply the character style
I could use help to refine the expression grep ((Figure|)) Table | Graph)\s\d+\.\d+) below to include Figure | Table | Graphic that have a two digits after the decimal point.
for example below works on "Figure 1.9" but not for 'Figure 1.10 '.
In addition, the expressions shown in the image below could be written to include the pural of each word, if there is a reference to a series? the list below
- Figure 1.9 and 1.10
- Tables 2.3 to 2.7
- Chart 3.4, 3.6 - 3.8 and 3.11
OK, the forum has excluded the \s in the expressionand put in a space.
(Figure |) Table | Graph)s*\s\d+\.\d+ will find as well singular and the plural of all three options.
-
Need to search and apply a character style sheet
I have a directory with the name and address of the student. I need to find 2 returns and replace with 2 returns, apply the character style, back. Here is a screenshot so you can see what I mean screen.
[Picture with private information removed by Moderator]
Allen, Davis must be condensed ital "BOLD" like Ahmed, Ehsan is above. Any help appreciated.
Post edited by: Peter Spier
Right. I have the impression that there is. As always... may be wrong.
-
Help with a script that detects the content in a cell and apply the cell style to line
Hello
I am trying to add an article to my table formatting script that is a cell with the word 'Budget' (but this can be written as ' Budget:' or ' Budget: (E) "- but without the speech marks) and apply the cell Style - SponsorCells - to all the cells of the whole line. I currently have on what it will, but it does not work:
function checkWhichTable() { // ensure the user made a selection if (app.selection.length != 1) return null; var currentTable = app.selection[0]; if (currentTable.hasOwnProperty("baseline")) { currentTable = app.selection[0].parent; } while (currentTable instanceof Cell || currentTable instanceof Row || currentTable instanceof Column) currentTable = currentTable.parent; if (!(currentTable instanceof Table)) { // No table selected return null; } return currentTable; } app.doScript(checkUserSelection, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Process Table"); function checkUserSelection () { var a_table = checkWhichTable(); if (a_table == null) { if (confirm("No table selected. Do you want to process *all* tables?") == false) return; allTables = app.activeDocument.stories.everyItem().tables.everyItem().getElements(); for (aTable=0; aTable<allTables.length; aTable++) { processTable (allTables[aTable]); } } else { processTable (a_table); } } function processTable(table) { // do something here! //Set 1st Row Height table.rows[0].height = "30mm"; //Find Text in Cell and apply Cell Style to Row var myCellText=['Budget', 'Budget:', 'Budget: (E)']; var myRegEx = new RegExp("^("+myCellText.join("|")+")$"); for (i=0; i<table.cells.length; i++) { if (table.cells[i].texts[0].contents.match(myRegEx)) table.cell[i].appliedCellStyle = "SponsorCells"; } //end - do something here! }
I can get the script to apply the cell style to "SponsorCells" for each cell that contain the word 'Budget' etc, but I need cell ever on this line to have the cell style applied. I tried to re-write line 56 which applies the style to a cell, but I can't seem to make it work. Any help would be great.
Separate on this issue, I would like to have a line of code similar to the 46 line, which sets the 1st height of lines, but I would like to say "If a cell has 'A cell Style' and then applies the value height 10 mm". If someone could result as a help of bonuses, things would be great double.
Thanks in advance!
But that could be painfully slow. To speed things up, follow these steps:
var cells = table.cells.everyItem().getElements(); for (var i=0; i
It is faster, because it creates an array of cells with a call to table.cells, which is several times faster than calling table.cells. And before assigning to line 12mm height is useful to check if it is already 12 mm. checking things in InDesign and do things only when it is necessary is much more effective than simply doing things even if they are not necessary.
-
Help with a script to search for text in a table cell and apply the cell style
Hello
I build the script which Jongware wrote in his post here http://indesignsecrets.com/tackling-tables-through-scripting.php - I am trying to create a variable in which I can add a number of different parts of the text, in this case it's different parts of the United Kingdom i.e. 'London', 'East', 'Scotland' etc. I just need the script to apply the cell Style - 'District Cell' - to any cell that contains text in the variable. Here's the script, if anyone can help I would be grateful.
function checkWhichTable() { // ensure the user made a selection if (app.selection.length != 1) return null; var currentTable = app.selection[0]; if (currentTable.hasOwnProperty("baseline")) { currentTable = app.selection[0].parent; } while (currentTable instanceof Cell || currentTable instanceof Row || currentTable instanceof Column) currentTable = currentTable.parent; if (!(currentTable instanceof Table)) { // No table selected return null; } return currentTable; } app.doScript(checkUserSelection, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Process Table"); function checkUserSelection () { var a_table = checkWhichTable(); if (a_table == null) { if (confirm("No table selected. Do you want to process *all* tables?") == false) return; allTables = app.activeDocument.stories.everyItem().tables.everyItem().getElements(); for (aTable=0; aTable<allTables.length; aTable++) { processTable (allTables[aTable]); } } else { processTable (a_table); } } function processTable(table) { // do something here! //Find Text in Cell and apply Cell Style var textInCell=['London', 'Scotland', 'South West']; for (i=0; i<table.cells.length; i++) { if (table.cells[i].texts[0].contents==textInCell) table.cells[i].appliedCellStyle = "District Cell"; } }
Hello
Change this feature:
function processTable(table) { //Find Text (exactly as it is) in Cell and apply Cell Style var textInCell=['London', 'Scotland', 'South West'], mFound, cFound; app.findGrepPreferences = null; app.findGrepPreferences.findWhat = "^(" + cities.join("|") + ")$"; mFound = table.findGrep(); while( cFound = mFound.pop() ) cFound.parent.appliedCellStyle = "District Cell"; }
Jarek
-
Table of contents does not include the Section prefix
The pages of this document in particular has a section prefix 'A', so the pages are numbered as well: a-1, A-2, A-3, etc.
When I run a Table of contents, the table of contents is generated without the prefix, as the following section:
Section 1... 1
Section 2... 5
Section 3... 9
Is there a way, or something I'm missing from the table of contents is generated as follows:
... Section 1 a-1
Section 2... A-5
Section 3... A-9
CS6, TIA
Discovered the problem. When the numbering, I thought that I had actually created a section prefix. I have not, I just typed in the 'A' before the current Page marker.
Maybe you are looking for
-
Unable to connect to wifi since the 10.0.2 update
I can't connect to wifi since updating to ios 10.0.2
-
Firefox keeps opeing where I left instead to start with my home page. I use the latest firefox with windows8. Dosen't happen with windows7. This has happened with the last update.
-
The only time where I get this message "cannot display the page of the page you are looking for is currently unavailable ', is when I come back to my Yahoo home page after visiting other websites and click"home. " My SSL settings are correct; I tried
-
Hi all I try to use my vi Analyzer, but when I open it, there is no test available (no comics, no FP test test, etc.). What is going on? Yik
-
All-in-One C200 / Win7 allways starts in VGASave mode with the NVIDIA drivers installed
Hello I have a problem with a C200 all-in-One (my mother-in-law). Allways Windows 7 starts in VGASave (vga driver regular) mode, but the NVIDIA ION drivers are correctly installed. Device Manager displays the NVIDIA graphics card and drivers installe