Multi-line plot titles in Pyxplot - gnuplot

Is it possible to make a multi-line plot title in Pyxplot? I do understand that the "set title" command accepts a LaTeX string and have tried to inject a newline in many ways.
Ultimately it seems that Pyxplot is just ignoring the newline directive. For example:
set title 'First line$\newline$Second line'
will generate a title that reads "First lineSecond line".
Is there a trick to make this work somehow?
I am using Pyxplot 0.9.2.

Per Christoph in the comments above:
You can try putting everything in a \parbox, see "10.15 LaTeX and Pyxplot": set title '\parbox{6cm}{\centering First line\newline Second line}'. I cannot test it, therefore I just post it as comment.
\parbox does seem to do the trick. I tested this and it did allow me to perform line breaks.
Thanks!

Related

vim/nvim line spacing when printing

I'm trying to use nvim for everything, including writing, and all is great but the text is too crammed when I print it out.
Is it possible to adjust the line spacing when printing with :hardcopy?
My idea of a kludge fix would be to insert a second newline character for every carriage return, including those automatically inserted by line wrapping. Is this possible?
One of the least frustrating ways to do it would be to use a tool like pandoc to convert the text (for example Markdown) to whatever format you need — preferably PDF. However, pandoc uses LaTeX to create the resulting PDF, so regarding the styling you would have to tinker with supplying it a template or other options.
You can do it even easier with (for example) a Node.js tool called mdpdf. After installation, just run
mdpdf file.md --style styles.css
to supply it with a CSS stylesheet in which you can modify the resulting text output with every feature CSS permits. Using larger line spacing would be something like this:
body { line-spacing: 150%; }
This results in a 1.5x line spacing for everything in the document.
Of course, you can also set up a custom Vim command to automate this for you, putting something like the following into your .vimrc:
command MdToPDF !mdpdf %:t --style /full/path/to/styles.css
Calling :MdToPDF in Vim will then run that command for you.
Finally, if you're happy with the output, just print the PDF.

when using vim-latex gq causes overhangs in captions

When I am editing a LaTeX file using Vim-LaTeX and want to reformat a section of text that is in a \caption{} I get overhangs or underhangs - I am not sure what to call them. I first select the text in the caption then use "gq" to reformat it. After reformatting the caption looks like:
\caption{The problem is that when I reformat the text
in a caption the text on each successive line
begins further and further to the left until it begins
at the first space of the line.}
what I would hope the result would look like would be something like:
\caption{The problem is that when I reformat the text
in a caption the text on each successive line
begins further and further to the left until it
begins at the first space of the line.}
I hope the formatting in this post remains true to what I typed in, but I tried to describe the problem in the first example caption. The second should be left justified.
Does anyone know what I need to do to fix this? I am assuming that there is a setting that I need to change, but I have not been able to figure out what it is.
The gq command formats based on 'formatexpr' or 'formatprg'. You can start by checking the values of these options with :se fex? and :se fp?.
From looking through the vim-latex plugin it never sets these options, so this is likely set by your other plugins or vimrc. You can find out exactly where an option is set by using :verbose.

Display underscore rather than subscript in gnuplot titles

Short question:
How do I display the _ (underscore) character in a title in gnuplot that is assigned from a variable name in gnuplot?
Details:
I have something like the following code:
items = "foo_abc foo_bcd bar_def"
do for [item in items] {
set title item
set output item.eps
plot item."-input.txt" using 1:2 title item with linespoints
}
This works fine with gnuplot except that the title get changed from foo_abc to fooabc. I don't know if I want to use an escape character because I don't want that to be in the file name. I've tried a couple of different options with single vs. double quotes but I haven't found what I need yet.
Instead of foo_abc, write foo\\\_abc.
Most gnuplot commands which generate labels accept a noenhanced keyword which will prevent gnuplot from using enhanced text for just that string. In this case, it should be sufficient to just do:
set title item noenhanced
An alternative is to create a function which will remove the unwanted text from the string when passing it to set output:
remove(x,s)=(i0=strstrt(s,x),i0 ? remove(x,s[:i0-1].s[i0+strlen(x):]):s)
# Makes me wish gnuplot syntax was more pythonic :-p
#TODO: Write a `replace` function :-). These just might go into my ".gnuplot" file...
I use an inline function to find the index of the first occurrence of x in the string s. I then remove that occurrence via string concatenation and slicing and recursively call the function again to remove the next occurence. If the index isn't found (strstrt returns 0) then we just return the string that was put in. Now you can do:
set output remove('\',item)
set title item
The underscore comes from treating titles as "enhanced text". Turn that off using
set key noenhanced
If you are using the enhanced eps terminal, that is the reason you need to escape the underscore in the first place. There was another related question today which explains the issue a bit. When you set the terminal, try:
set terminal postscript noenhanced <whatever else here...>
That works for me (Arch linux, gnuplot 4.7.0). If the enhanced terminal is essential, below is a partial solution I found. The assumption is that the underscore always appears in the same place in the string.
set terminal postscript enhanced
items = 'foo\_abc foo\_bcd bar\_def'
do for [item in items] {
set output item[1:3].item[5:*].'.eps'
set title item
plot sin(x)
}
This way you can escape the underscore and not have the \ appear in the filename. Note the use of single quotes for the 'items' string; see the previously linked question for details.
I had the same problem about the underscore in the title: such as I needed to write 4_3 subframe and I needed the enhanced postscript. The SIMPLEST way turned out to be from the adjacent post: ``If you are using the enhanced eps terminal, that is the reason you need to escape the underscore in the first place. There was another related question today which explains the issue a bit." - How is # produced in gnuplot?
So, I followed their advice and this worked:
plot 'LC.stats' u 3:4 ti "{/=15 1350 stars in C18 4\_3 subframe}" -
Double escape character before the underscore.

VIM hide (not fold!) lines

Is there a way to totally hide certain lines? I do not want folding, I one them to not be visible at all.
Example: I program with php; functions and class variables have phpdocs, and I hate how much vertical space lines with nothing but /** and */ can take. Thus I would like to not show them (and most likely some other things). Though I have doubts that that is possible...
Note: I know about global commands and they don't do what I want. You can one of printing of what I want. But I want lines hidden in the editing area.
You can make comments invisible:
:hi! Comment guifg=bg ctermfg=white
Or
:hi! link Comment Ignore
I know this isn't really what you're asking for, but have you tried using folding with a blank foldtext? That way the lines a folded region appears like an empty line. To do this, set
set foldmethod=marker
set foldmarker=\/**,*\/
set foldtext='\ '
I prefer a foldtext which indicates that there's something there, possibly by making is look like a single commented line. In this case, replacing the first folded line with a single comment string // at the current indent level:
set foldtext=substitute(getline(v:foldstart),'\\/\\*\\*.*','\\/\\/','g'
I find this unobtrusive, while still reminding me that there is some hidden text.
Hope this helps.

Remove all arbitary spaces before a line in Vim

I'v written a plugin where it comes to parsing a XML tag. The content inside the tag is indented and when i copy the parsed string into the file it's gettting like:
Example line
This is part of the parsed line
Thats goes one
End of line
What I want is to remove all spaces in front of these lines, the final text should be
Example line
This is part of the parsed line
Thats goes one
End of line
I've tried to use = but it doesn't work the way I want. How can I do that with minimal key strokes ?
To format a line to the left I use :left. Use this format an entire file:
:%le
A simple search/replace s/^\s*// should do the trick, but it's probably not the minimal version.
Personally I would visually select the lines with V, then use 99< to push the text as far left as it could go.
Just type d followed by w followed by j at the beginning of each line.
How about this:
:%s/^ *//
Or are you looking for a vim-script solution?
To remove initial spaces and tabs at specified line numbers (E.g. from lines 5 to 10),
:5,10s/^\s*//
Yet another way to achieve this is using the the normal command :h :normal-range
:%norm d^
This goes to column 0 in each line (%) and deletes (d) to the first non-white character(^).
This is slightly more to type as the accepted answer, but allows for easy extension if you have a more complex scenario in mind, such as additional un-commenting or so:
:%norm d^I#
Resulting in:
#Example line
#This is part of the parsed line
#Thats goes one
#End of line
The search/replace suggested by Lukáš Lalinský or the %le approach in the wikia page is probably the way I'd do it, but as another alternative you could also do:
:%< 99
As a quick way to shift the whole file (%) 99 times to the left.
Remove all consecutive spaces: :%s/ */ /g
It was useful to me to go from:
$screen-xs-min: 480px;
$screen-sm-min: 768px;
$screen-md-min: 992px;
$screen-lg-min: 1200px;
To:
$screen-xs-min: 480px;
$screen-sm-min: 768px;
$screen-md-min: 992px;
$screen-lg-min: 1200px;

Resources