Publishing made easy with publish configurations
The publish function has been around since R14 and has proved useful for a number of things, to include demonstrating concepts, creating reports and generating blogs. In R2008a we’ve made it easier to fit publishing into your work flow, by introducing publish configurations, younger brother to run configurations (introduced in R2007b).
The most significant change is that you can now have multiple sets of publish options associated with a single file – previously there was a single set of global publish options. This added flexibility allows you to more easily publish different files with different options and even publish the same file with different options.
To get aquatinted with this new feature, let’s look at how our very own Loren of Loren on the Art of MATLAB uses publish configurations in her workflow.
Once Loren is happy with the entry, it’s time to publish it to HTML. One of the restrictions when publishing her blog is the width of the images – too wide an image causes scroll bars and layout problems, so she likes to restrict image width to 500 pixels.
Here’s are the steps Loren follows in order to take advantage of this new feature:
Draft Phase – Publishing to Word
Step 1: Once the draft is ready for spelling and grammar checking, open the configuration editor by clicking the drop down arrow next to the publish button and select Edit Publish Configurations for [your_file.m]:
This automatically creates a publish configuration with the name of your file (‘foo’ in the figure above). You can also specify input to the function you’re publishing, as I’ve done above.
Notice that there are two sets of Publish Settings that ship with MATLAB: Factory Default and User Default. Every new publish configuration you create, will use the User Default settings, which you can change if you’d like (see the doc for how to do this). But you can also create custom sets of settings. In the next two steps we’ll create a custom set of publish settings that we can use now and in the future each time we want to spell check and grammar check our work.
Step 2: Change the Output file format to doc:
Notice that a dot is shown next to the Output file format setting, indicating that our settings have deviated from the User Default settings.
Step 3: Now click Save As… in the configuration editor and type Word for the Settings name in the Save Publish Settings As dialog. When you’ve finished typing the name click Save:
This creates a new set of publish settings that will be used in the current publish configuration. These new settings will also be available to use in other publish configurations via the Publish Settings combo box:
Step 4: Click Publish in the configuration editor and review the document.
Blog Phase – Publishing to HTML:
OK…the spelling and grammar have been checked and we’re ready to upload the blog entry to the web. Next we’ll open up the configuration editor again, create a new publish configuration and create another set of reusable publish options for blog posts.
Step 5: Press the add button in the configuration editor and select Publish Configuration:
This creates a new publish configuration associated with your file, which is named ‘foo_2’ in the example above. This configuration uses the User Default publish settings, and because the default output format is html, we don’t have to change this setting.
Step 6: Now change the Max image width (pixels) to 500:
Finally, press Save As… in the configuration editor and type Blog for the Settings name and click Save (as we did above).
Step 7: Click Publish and upload to the web!
Loren’s MATLAB file now has two publish configurations, one using the Word publish settings, and one using the Blog publish settings. Each time Loren creates a blog entry, she can create a publish configuration for her MATLAB file and select the publish settings appropriate for her current task (spelling and grammar checking or getting ready to upload to the web).
MATLAB saves all the configurations for every file, as well as the publish settings that are used within the configuration. This makes it easy for Loren to consistently publish a file with the same settings.
Give Publish Configurations a Try!
Your work flow and ultimate product may be different from Loren’s, but the publish configurations can reap the same work flow benefits for you. Let us know how you use this feature!
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.