custom paper size on the command line? - lilypond

I'm working with three different paper sizes, i.e. the same music formatted for different page sizes. This works fine for established paper dimensions.
lilypond -dpaper-size=\"letter\" -o "outFile-L" sourceFile.ly
or
lilypond -dpaper-size=\"statement\" -o "outFile-S" sourceFile.ly
But I also use a paper size not available in the paper.scm file. Here's the code I use.
#(set! paper-alist (cons '("booklet" . (cons (* 7.0 in) (* 8.5 in))) paper-alist))
#(set-default-paper-size "booklet")
I'd really prefer it if I didn't have to edit each file to turn on/off the "booklet" page sizing. Unfortunately if I try specify "booklet" on the command line it errors because the compiler sees the command line option before it reads the definition in the code: warning: Unknown paper size: booklet
I can imagine two different solutions:
1) Add "booklet" to the paper.scm file, with the understanding that every time Lilypond is upgraded I'll have to re-do the edit.
2) Create a common file that all music files have to source, but there are different versions of the file in different sub-directories, and that sub-dir is directed from the command line.
lilypond --include="./bookletDir" -o "outFile-B" sourceFile.ly
Any other (better) suggestions?

Related

How to set silent_functions(1) as default in Octave? [duplicate]

I'm new to octave, and want to run a few commands on startup automatically every time it opens.
I typed "help startup" and saw "Octave uses the file ".octaverc". I did a bit of searching online at https://www.math.utah.edu/docs/info/octave_4.html, and saw the .octaverc file should be in the following path:
OCTAVE_HOME/lib/octave/VERSION/startup/octaverc
PROBLEM:
In that directory I don't have a startup folder, only "oct" and "site". I do see hidden files, which was my first thought since the file begins with "." character. So I then used Agent Ransack in the directory, and still nothing came up.
QUESTION:
1) Do I have to make the startup folder and octaverc file myself?
2) If so, does one, both or none have to be hidden?
3) Can it be a txt file, or does it have a special extension?
4) Do I just type the commands straight into the file or is there special formatting?
NOTE:
In case I'm going about this the wrong way, there are the operations I'd like to have run on startup:
PS1('>> '), addpath('D:\Users\Me\Desktop'), clc
Thanks ahead of time for the help!!
Possible locations (and their differences) for octaverc files are specified in the documentation.
In short, these are, from more general to specific:
octave-home/share/octave/site/m/startup/octaverc (most generic, for entire system)
octave-home/share/octave/version/m/startup/octaverc (to cover for more than one octave versions installed on the system, possibly requiring different startup scripts)
~/.octaverc (where ~ is unix-speak for a user's home directory -- covering for user-specific startup files)
.octaverc files in any directory, creating specific startup conditions for specific directories
octaverc files are effectively simple script files that are executed from most generic to most specific each time octave starts. Therefore, in the presence of conflicting commands, the more specific file can effectively be used to override the more generic behaviour.
Octave also supports (but does not recommend) the use of the startup.m file, for matlab compatibility.
You might also want to check out pathdef and savepath as well.
As a more general tip, if you ever want to search for a specific keyword from the documentation (e.g. octaverc), you can type this kind of search query in duckduckgo (or google):
octaverc site:https://octave.org/doc/interpreter/
(or just download the documentation as pdf and search the pdf)
Found the solution, the file was in the following path:
OCTAVE_HOME/share/octave/site/m/startup
to find out where OCTAVE_HOME is for you, just type "OCTAVE_HOME" into your Octave command line window.
ANSWERS:
1) You do not have to make a startup octaverc file yourself
2) The file is actually not hidden, so it should be easy to find given you're looking in the right place.
3) The file doesn't have an extension. It's just octaverc.
4) Under the last line of the existing file, you can just append commands as you would type them at the Octave command line window.
the last(7.3.0) octave version placed HERE:/ does not find the THERE:/openEMS/matlab directory even it is already loaded with octaverc or addpath. It keeps looking into the work dir where openEMS is not placed and does not recognize, for instance, the 'physical_constants.m' file.

How to adjust page size while publishing?

Software: Octave v7.1.0
There seems to be no option of defining the page size while doing publish ("FILE", "pdf") . The manual for pdf is: 11.11.1 docs.octave/.../Publish.
It's kinda surprising as it's a one word addition to the output TeX file : a4paper. I can do this manually each time I publish but being able to specify it somehow within the publish function would be awesome.
Surprisingly, there are plenty options for specifying page size in figures and images. Search for papertype at: 15.3.3.2 docs.octave/.../Figure-Properties
I searched with "Matlab" and found this page, and it fetched the results for "Matlab Report Generator" mlreportgen which seems a different thing.
I'd be interested to listen about other ways of doing it automatically too (like adding that word in TeX file via shell scripting and text string manipulation maybe).
As directed by #cris-luengo in the pointer comment to the linked manual, one solution can be to edit (or create) the function files (to used by the publish function) with the desired changes to specify the paper size.
The function files location can be found by:
opening the function file in octave gui and then proceeding from there:
edit (fullfile (fileparts (which ("publish")), "private", "__publish_html_output__.m"))
or, executing the following in octave REPL/command line:
fullfile (fileparts (which ("publish")), "private")
There, among other files, 2 files will be:
__publish_html_output__.m
__publish_latex_output__.m
Edit the _latex_ containing file to add ,a4paper (or other predefined size in latex) alongwith 10pt in the line '\documentclass[10pt]{article}',, optionally with a comment in a proceeding newline as a reminder that you added it, something like: '% Modification: specify a4paper',
If pdf format were directly specified as a new function file, then I'd have preferred to modify its copy and calling that directly in publish(), but since the publish pdf eventually calls publish latex, so, the only option at hand in this method seems to edit the original publish latex function file itself.

How can I get Octave GUI to load/read .m files correctly in editor and console?

I am taking a class on using Octave for machine learning algorithms, and as part of the assignments, they provide a series of .m files to build upon with our own code as well as to run for submission credit through the auto-grader. My problem is that the .m files load perfectly fine in a regular text editor program like Atom or Notepad, but in Octave, the files are best described as nonsense, and thus will not run in the console. If I open the files in a regular editor and copy/paste over the crazy into Octave, it seems to save it and reopen fine. But, I have close to 20 files for the first project alone, and this solution is untenable in the long run. I have a screenshot of how it's loading. Is there some setting I need to change? Uninstall/reinstall Octave? I'm new to Octave and the Octave GUI, and I'm striking out with Google for a solution. I am using version 6.2.0. Thank you for any help/advice!
screenshot of how octave is loading my .m files
Update: I responded to this in a comment below, but I tried loading it another way into Octave GUI and received the following error: ">> error: load: unable to determine file format of 'C:/Users/sophi/documents/octave/assignment_1/computeCost.m" This tracks for me because it makes sense why it would open the files in such a weird way. It's simply not sure what they are. However, I created my own simple functions from scratch to test, saved them as .m files, and was able to run them perfectly fine. I'm including one of the files below. Maybe there's a key in the formatting of the files offered by the class which is impacting Octave's ability to process it correctly?
function plotData(x, y)
%PLOTDATA Plots the data points x and y into a new figure
% PLOTDATA(x,y) plots the data points and gives the figure axes labels of
% population and profit.
figure; % open a new figure window
% ====================== YOUR CODE HERE ======================
% Instructions: .... goes on about assignment
% ============================================================
end
MOST RECENT UPDATE: The plot thickens. Yesterday, I was able to open the files I created and run them in the Octave environment, and I (wrongly) assumed they would still work today. They are doing the same stupid thing as the files included by the course. I checked inside preferences for the editor, and it says it is loading and saving them as IBM273 if that helps. Thank you for everyone has pitched in ideas. I really appreciate it!
It was 100% the encoding. I thought it was strange it was saving/loading in IBM273, so I switched it to UTF-8. Almost all the files are working now. The only ones that aren't are the ones I was trying to copy/paste yesterday to see what was going on with the load problems and the basic new problems I wrote. So I deleted everything, redownloaded, and set the default UTF-8 going forward and voila! Solved! Thanks again!
If you want to open a .m file in octave, Try this solution
It is necessary to declare a current directory before saving a file, loading a file, or running an M-file. By default, unless you edit the Octave shortcut, the current directory will be .../Octave/work. After you start Octave, change the current directory by either using the toolbar at the left-hand side of the screen, or entering the path in the bar at the top.
To open an .m file, you can use file -> open, or type
open filename

OCR detecting E as £

I am using pytesseract (version 5 of tesseract) to scan an image. I have changed image to black and white to remove the noise but still E is being detected as £196893 .
Also tried setting the language, dpi and psm values which has been suggested by most of people. Below are the settings I am using now. Please suggest.
pytesseract.image_to_string(Image.open(impath), config=" --dpi 120 --psm 6 -l eng")
Once of sample picture is shown below. For some samples it is working fine but for some samples it is giving such strange characters.
A solution to overcome this issue is to limit the characters that Tesseract looks for. To do so you must:
Create a file with arbitrary name (i.e. "whitelist") in tesseract config directory. In linux that directory is usually placed in /usr/share/tesseract/tessdata/configs.
Adding a line in that file containing only the characters that are you want to search in text:
tessedit_char_whitelist *list_of_characters*
Then call your script using the whitelist vocabulary:
tesseract input.tif output nobatch whitelist
In this case the parameters must be setted in your Python script as:
pytesseract.image_to_string(Image.open(impath), config=" --dpi 120 --psm 6 -l nobatch whitelist")

is it possible to nmap two consecutive commands to the same pane in vifm?

I would like to create an nmap that would first cd to a particular directory and then edit a file in that directory. For instance, this would allow me to open a LaTeX file and edit it, but then exit from that file and be in the directory to pull up the pdf file that LaTeX created. I have tried the following:
nmap b :cd /path/to/directory/ <cr> :edit file.tex
This almost works and will suffice if it is the only way to do it. What happens is that the left pane changes to the correct directory and the file is opened in the right pane. Then when I quit I only need to move between panes to get to the other files. However, it would be simpler/cleaner if I could get both commands to happen in the same pane.
Is this possible?
Thanks
The reason why two commands happen in different panes is that RHS of your mapping contains a space in normal mode (right after <cr>). You should either remove it or don't switch between modes at all by performing two commands in a row (which should be separated by a bar/pipe):
nnoremap b :cd /path/to/directory/ | edit file.tex<cr>