I have thousands of lines of MATLAB ranging over several scripts that I have commented and broken up into cells. I would now like to publish. I have some universal formatting that I would like to apply. I would also like to be able to publish each script independently. At the moment I have written all these formats into a file called 'Formats.m'. So at the start of every script it publishes with the word 'Format' at the top.
Is there a way I can call in the formatting file without seeing the name published in the final script?
publish has an option codeToEvaluate which might be what you're looking for here.
To publish foo, but run Format first, try this:
>> opts.codeToEvaluate = 'Formats; foo';
>> publish('foo',opts)
If you're working from the Editor, the same option is available as a publish configuration.
Related
I am trying to export a larger number of Matlab figures that are generated in for loop to a single PDF file. Right now the best thing I could come up with is to all print them to a PostScrip file using the -append option like this:
print('Temp_Plots','-dpsc','-append')
After that I could convert the PS file to a PDF file. This workflow was okay until I started to use plots with 2 y axis. Unfortunately it seems like Matlab's PS export cannot properly handle this situation and does not color the lines appropriately.
As there is no -append option for the direct PDF export what other methods do I have to append all my plots to a single file without losing the assigned colors or other hickups?
I would recommend trying out the publish command and push that to its limits first.
Following the documentation:
options = struct('format','pdf','outputDir','C:\myPublishedOutput');`
publish('myCode.m',options);
Take a look at Publishing Markup to see how to get the look you want.
This search brings up some possibly related posts, but none that I saw that directly match your issue.
References:
1. Publishing Markup (Mathworks)
2. Output Preferences for Publishing (Mathworks)
3. Publishing M-Files in MATLAB
4. Publish Your Work in Matlab
Is there a way to fold sections of codes in Live Scripts as there is in regular scripts?
I have tried to look for it in the preferences and enabled all kind of foldings, but none of them relate to the Live Scripts. I would expect it to work since the notation of %% is similar in both types of scripts.
Any idea how to enable/workaround this?
No, I don't believe you can do this. Seems like a nice thing to want to do, though, so I would enter an enhancement request with MathWorks. I have no suggestion for a workaround, I'm afraid.
I know this is old but in case anyone else is wondering, below are the workarounds suggested to me by tech support when I submitted an enhancement request. I encourage the reader to add their vote by submitting a request if they still want to see this feature added to the live editor.
Convert to M file and "publish" with 'showcode' as false. First, convert the Live Script into an M file. You can do this interactively
by clicking "Save As" and then choosing the "M" file option in the
File Type section or you can do it programmatically as follows:
>> matlab.internal.liveeditor.openAndConvert('live_script_to_be_converted.mlx',
'output_script.m');
Once you have the converted M file which has all the section breaks
and formatting, you can use the "publish" function as follows from the
MATLAB Command Window:
>> options.format = 'pdf';
>> options.showCode = false;
>> publish('output_script.m',options)
This will publish the PDF file to a sub-directory called "html" inside
the current working directory.
Here is a documentation link for the "publish" function and
specifically, the "showCode" option:
https://www.mathworks.com/help/matlab/ref/publish.html#input_argument_namevalue_d119e823467
Please note, when saving the MLX file as M file and then publishing,
it does not convert the LaTeX expressions to something readable. It
also automatically inserts a table of contents at the beginning.
Encapsulate the code in another script or function. An alternate approach would be for you to encapsulate the code you want to hide in
another script or function and call it from your published Live
Script. For example, something like:
>> %% Now plot a figure
>> functionThatPlotsAFigure
In this case, instead of publishing all the plotting code, only the
call to the plotting function would be published.
Publish the Live Script as an HTML and then modify the HTML page to hide the code sections and then publish it as a PDF.
The options stated above are simply workarounds as we do not currently have this functionality. A request has been submitted to our developers to add in this feature and they are considering this for future releases of MATLAB. We appreciate your feedback as we constantly strive to improve our products.
I am trying to separate out internal and external documentation using the doxygen constructs of cond; but i just cant seem to get get it working. I would essentially like to exclude some files completely and not conditionally. Regardless of where i add the tag (before include, before header guards etc) , the files and source both show up.
What i have tried in vain is to take the test file from doxegen repo for
conditional test and add it to the project.
Steps to reproduce [Linux]
create a new directory.
copy paste the above file (had to rename it to .h as .c was passed over?).
generate dummy config via doxygen -g.
update Doxyfile ENABLED_SECTION = COND_ENABLED.
Run doxygen.
check html/index.html
This however is still visible in the html documentation it generates for the project. I have set the ENABLED_SECTION variable with other values , but cond_enabled function still shows up. Running the testing directory of the project (doxygen) it passes. So i am lost.
Any suggestions?
Tried with latest version 1.8.14.
Thanks!
Regarding the \cond problems (not an answer directly to the real problem you face, I think, but to long for a comment).
The mentioned file is used in the, limited, testing doxygen can do / does and the first lines contain some instructions on what to do. Furthermore there is a default Doxyfile with the tests in use. It is hard to run a separate test outside the doxygen build tree.
Regarding the remark "Running the testing directory of the project (doxygen) it passes." This is correct, here, at the moment, only testing is done against the XML output and the generated output is compared to a once created version of the XML output. No tests are done, at the moment, in respect to HTML or PDF / LaTeX. Recently the test framework has been slightly extended so in the future this should be possible (compare the xhtml and tex output, but some work has still to be done here).
The version of the parser sees the \cond in the first line (normal C comment) as a doxygen command and skips everything till the first \endcond (your friend in these cases is always doxygen -d preprocessor). I think that removing / modifying the first line will result in an already better result. There is however another hiccup for e.g. HTML output. As the function cond_enabled is not documented and EXPAND_ALL is not set to YES the function will not appear in the documentation. So best is also to add a line of documentation with the function cond_enabled.
Regarding the seen HTML problems I modified the the relevant test in doxygen slightly and pushed a proposed patch to github (pull request 714, https://github.com/doxygen/doxygen/pull/714).
Note: the problem of skipping the \cond in normal C comment is quite a bit harder to implement (seen the logical complexity of the doxygen code in pre.l and commentcnv.l.
EDIT: 2018/06/10: The push request has been integrated in the master version on github.
I need a diff tool that has a command line option to create and save a diff report that looks easy to read, something like the html report produced by WinMerge. I have a few hundred files that I need to compare and it's not practical to have to open the files and manually and save the report.
I did find a tool that does exactly that: http://sourceforge.net/projects/diff2html
It's a bash script that uses diff(1) and creates an HTML page from the output with colour-coded diffs.
Have you looked at the command line option in WinMerge? http://manual.winmerge.org/Command_line.html
You might need to use something like AutoHotkey to automate saving the reports created by WinMerge: http://www.autohotkey.com/
Is there a LaTeX command that prints the "last modified" date of the actual document? Since LaTeX projects consist of more than one file this command ideally prints the date of the actual file, not that of the project.
pdfTeX provides the primitive \pdffilemoddate to query this information for files. (LuaTeX uses its own Lua functions for the same thing.) Since pdfTeX is used by default in all LaTeX distributions in the last few years (at least), there's no harm in using the new functionality unless you're dealing with very old production systems. Here's an example:
\documentclass{article}
\begin{document}
\def\parsedate #1:20#2#3#4#5#6#7#8\empty{20#2#3/#4#5/#6#7}
\def\moddate#1{\expandafter\parsedate\pdffilemoddate{#1}\empty}
this is the moddate: \moddate{\jobname.tex}
\end{document}
(Assuming the file has been modified since year 2000.)
The package filemod seems to do exactly what you need. To get the last modified date of the file you just include the package in the usual way:
\usepackage{filemod}
and the modification time of the current document is printed by:
\filemodprintdate{\jobname}
you can also print the modification time, and there are many options to format the output.
Unfortunately, TeX does not provide commands for such information; the only way to get such information is
by running a non-TeX script to create a TeX file before running LaTeX and including this file in your main LaTeX document somehow, or
by running the external script from TeX (which only works if the so-called write18 or shellescape feature is enabled; you'd have to consult the manual of your TeX implementation for this, and not have a stubborn sysadmin).
It is possible that extended TeXs do support file info commands (luaTeX perhaps?), but it's not part of TeX proper.
If you are using an automated build system, you could ask it to generate a file (perhaps named today.sty) which depends on all the source files.
In make that might look like:
today.sty: $LATEX_SRCS
echo "\date{" > $#
date +D >> $#
echo "}" >> $#
and \usepackage{today.sty}.
The will use the date of the first build after a file changes, and won't update until either you delete today.sty or alter another source file.
thank dmckee
LATEX_SRCS = test.tex
define moddate
date +%Y%m%d%H%M%S
endef
today.sty: $(LATEX_SRCS)
#echo "\def\moddate{"$(shell $(moddate))"}"> $#
There is the getfiledate LaTeX package (it was part of my LaTeX distribution by default). It seems to be designed to automatically output a paragraph like:
The date of last modification of file misc-test1.tex was 2009-10-11 21:45:50.
with a bit of ability to tweak the output. You can definitely get just the date. However, I couldn't figure out how to get rid of newlines around the date and how to change the date format. To be honest I think the authors implemented it exactly for the single purpose they needed it, and it is rather cumbersome for general use.