Title case macro

Get help using and writing Nisus Writer Pro macros.
Post Reply
writerhoward
Posts: 50
Joined: 2013-02-03 05:10:26

Title case macro

Post by writerhoward »

Is there a script that will convert selected case to "title case"?

Howard
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Title case macro

Post by phspaelti »

Have a look at the following discussion:
http://www.nisus.com/forum/viewtopic.ph ... title+case
philip
writerhoward
Posts: 50
Joined: 2013-02-03 05:10:26

Re: Title case macro

Post by writerhoward »

Philip,

Thanks for the link. How do I open, change, and save the capitalization macro?

Can I save the Title Case macro in "Format | Character Case" so it appears as "Display as Title Case"? If so, how can I do that?

Howard
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Title case macro

Post by phspaelti »

writerhoward wrote:Thanks for the link. How do I open, change, and save the capitalization macro?
If you have downloaded the folder you can just double-click on the files and they will open, and show you the code of the macro. You can edit the code, provided you know what you are doing :wink:
But most likely you don't need to change the macro. One of the two macros is for adjusting the list of words you want exempted from being capitalized. You can adjust that list anytime--by running the relevant macro--and that list will be active from that point on forward. This whole approach to Title Case is far from perfect. Hopefully Nisus Writer will have a more properly built-in Title Case feature someday soon.
You can use the macros, either by using "Add Macro to Menu from File…" or by saving/moving the macro(s) to the Nisus Macro folder. The macro folder can be organized using sub-folders. The folders inside the macro folder appear as sub-menus.
If you want the macro(s) to have a different name (in the macro menu), just change the name of the macro file before or as you save it.
writerhoward wrote:Can I save the Title Case macro in "Format | Character Case" so it appears as "Display as Title Case"? If so, how can I do that?
No, this can't be done. Macros are available through the macro menu only. But you can of course assign a keyboard shortcut to a macro to make it more convenient to call, or you can also add a macro as a button on your toolbar if you like.
philip
writerhoward
Posts: 50
Joined: 2013-02-03 05:10:26

Re: Title case macro

Post by writerhoward »

Philip,

In the style guide I follow for academic papers, all prepositions within a title are not capitalized. So, if I did not want "about" to be capitalized, would I just add it to $defaultList in the Title Case Exempted Words macro in the correct alphabetical position and then save the file?

Howard
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Title case macro

Post by phspaelti »

Howard,

no you don't need to change the default list. In fact if you have already run the macro once, changing the default list will do nothing.
But adjusting the list of words that you want to exempt is what the "Title Case Exempted Words" macro is for. Just run the macro and add (or remove) any words you want. The macro is going to store the list of words in a special user registry, so after you adjust the list, that list will continue to be active on your computer 'forever'. If you want to change the list, or check what's in the list, just run the macro again.

Here is what it will look like if you run the macro to add some prepositions to your list:
Title_Case_Macro.png
Title_Case_Macro.png (21.47 KiB) Viewed 16127 times
So run the macro, and add all the prepositions you need. If you later find that you have missed some, just run that macro again.
After you have set the list to your liking, the Title Case macro will capitalize all words in your title except for whatever is in your list.

Hope this a bit clearer now.
Philip
philip
writerhoward
Posts: 50
Joined: 2013-02-03 05:10:26

Re: Title case macro

Post by writerhoward »

Philip,

Thanks for the excellent reply. I was able to add words to the "Title Case Exempted Words" macro; however, when I run the "Title Case Capitalization" macro, the same screen appears as for the "Title Case Exempted Words" macro in which you can add/edit exempted words. I did select text to be changed, but that was unaffected.

Howard

Update: Somehow I got it to work -- sometimes. If I type a line, select it, and apply the capitalization macro, sometimes it works. It did not change this, however, though I added "Above" to the exempted list: The Above Is Not A Good Title. Also, sometimes, it works, I make a change to a word's capitalization, reapply the macro, and it does not work. For example, when I changed The "Above Is Not A Good Title" to "This Is The New Title," it did not lowercase "The."
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Title case macro

Post by phspaelti »

Hello again,
I'm sorry that the macro is giving you such a hard time.
writerhoward wrote:Also, sometimes, it works, I make a change to a word's capitalization, reapply the macro, and it does not work. For example, when I changed The "Above Is Not A Good Title" to "This Is The New Title," it did not lowercase "The."
Wait a minute here. This is not what the macro is for. This macro is explicitly not about fixing your capitalisation. This macro only applies the "Display as Capitalized" style to your title in a manner that is consistent with 'true Title case', i.e., capitalisation that exempts certain 'unimportant' words. So if you capitalise "The" the macro respects this and leaves it unchanged. In fact since 'the' is an exempt word it won't even apply the "Display as Capitalized" style, so it's just showing you what you typed.

Of course one could have the macro first force lowercase on all the selected text. I think that would be stupid. What I suspect you really want (Who wouldn't?) is truly smart capitalisation, i.e., the kind that knows what needs to be capitalised and fixes things accordingly. But that is a linguistic problem, and computers can't do that. And I personally hate applications that think they can do that. [Rant about grammar checkers deleted.]

If there is a flaw with my macro as currently implemented, it has to do with the problem that I was writing about in the other thread. (http://www.nisus.com/forum/viewtopic.php?f=18&t=5651) That is, since it applies "Display as Capitalized" to whole words, it actually turns "USA" into "Usa" and the like. So here is a version that fixes that problem:

Code: Select all

[macro removed]
Anyhow I hope that clarifies where things stand. Personally I capitalise my text by hand. :)

Update: I am now uploading a revised version of the macro(s) along with a third macro, which allows one to remove the registry variable. This version also fixes some minor flaws, of the previous version. I also added a 'read me' file with some brief explanations on how to use the macros.
Title Case Macros.zip
(16.32 KiB) Downloaded 929 times
philip
Post Reply