Since you have asked for a macro script to convert the subsection into titlecase, you can try this script:
%SCRIPT
matches = triggerMatches;
title = matches[matches.length-1];
words=title.split(' ');
cursor.eraseLine();
editor.write("\\subsection{}");
cursor.movePosition(1,cursorEnums.Left);
editor.insertText(words[0][0].toUpperCase()+ words[0].substr(1).toLowerCase()+" ");
for (i=1; i<words.length-1; i++) {
if([";",":"].indexOf(words[i-1].slice(-1))>=0){
editor.insertText(words[i][0].toUpperCase()
+ words[i].substr(1).toLowerCase()+" ")
}
else{
if (["amid", "mid", "apud", "as", "at", "on", "atop", "bar", "but", "by",
"chez", "down", "for", "from", "in", "into", "less", "like", "near",
"of", "off", "on", "onto", "out", "over", "pace", "past", "per",
"post", "pre", "pro", "qua", "sans", "sauf", "than", "thru", "to",
"til", "up", "upon", " pon", "vs.", "via", "vice", "with", "w/",
"w/i", "w/o", "for", "and", "nor", "but", "or", "yet", "so", "a",
"an", "the", "some", "to"].indexOf(words[i].toLowerCase()) >= 0) {
editor.insertText(words[i][0].toLowerCase()
+ words[i].substr(1).toLowerCase()+" ");
}
else {
editor.insertText(words[i][0].toUpperCase()
+ words[i].substr(1).toLowerCase()+" ");
}
}
}
editor.insertText(words[words.length-1][0].toUpperCase()+ words[words.length-1].substr(1).toLowerCase());
You can add a triger, in my case the triger is:
(?<=\\subsection\{([^}]*)\})[t]
So when you just type the letter "t" after the braces of any subsection, it will change to titlecase.