define a rectangle in elisp code - elisp

I want to put a rectangle of text into an elisp variable.
At the moment, I'm using extract-rectangle in the elisp file which is loaded with --load at the command line, and the text to extract (the rectangle) is in the target file (the file doing the loading).
But to change the rectangle I must edit the rectangle in the target files and the rectangle's bounds in the elisp file.
It would be nicer to edit only the code (the loaded file), not both, and not have to change the rectangle's beginning and end points.
Anyone know how to do this?

OK, figured it out myself - the key I was missing that a rectangle's a list of strings.
my test code's below -
(setq killed-rectangle'(" a b 1" "cd " " ef"))
(yank-rectangle)

Related

how correctly set the label positioned in the middle of the label with zpl code

My code is here:
http://staging.advanced-technology-group.com/?density=8&quality=grayscale&width=4&height=6&units=inches&index=0&zpl=%5EXA%0A%0A%5ECI28%0A%5ECWZ%2CE%3ATT0003M_.FNT%0A%5EFS%5EXZ%5EXA%5EFWN%5EFO70%2C50%5EA0%2C30%2C25%5EFH%5EFD_ce_8e%0A%5EFS%5EFO70%2C90%5EBY2%5EB3%2C%2C100%5EFDtestprodcuct%5EFS%5EXZ
The problem i face, is that i calibrate the zebra printer (gc 420t) with the following:
hold the feed button, the led blinks once, then twice, then i release the feed button.
Then i notice that half of the label is not printed. Given that i use the above offsets. What should one do? There are two ways to make the label print correctly. Either with the printer make it print the label in the middle, or with putting instead of 70, a larger value in the FS command. How would you suggest i should proceed? If i use the code, is there a command to use instead of FS, a command that would tell the printer to print the label in the middle of the paper?

Autocad angle customization

I am new in AutoCAD and I try to do a figure but I don't know why my autocad don't work.
This is what I try to do --> Here <--.
But even if my paint look the good angle Screenshot_1 - there write 54.6<47.18) when I press enter my AutoCAD draws the line like that: Screenshot_2 (from above link)
Any suggestions to "repair" this settings or to enable/disable the option that make this happends.
Sorry for every language mistake.
56.5685<45 specifies absolute polar coordinates (from UCS origin)
#56.5685<45 specifies relative polar coordinates (from last point) see here.
When You Want to Make a Angle in AutoCAD in the Command Line for Eg. Say
Command: L
LINE
Specify first point:
Specify next point or [Close/Undo]: #250<35
Here "#250" is the Length of the Line & "<35" angle in which the Line is Needed.
This is what you have to do..

Simple file legend in Xmgrace

I am using xmgrace to plot several graphs on a shared axed, from a two-column data file like so:
# title "RMSD"
# xaxis label "Time (ns)"
# yaxis label "RMSD (nm)"
#TYPE xy
# subtitle "C-alpha after lsq fit to C-alpha"
1.7125001 0.0005074
1.7225001 0.0635904
1.7325001 0.0747008
1.7425001 0.0707590
1.7525001 0.0821623
1.7625000 0.0842335
1.7725000 0.0929994
1.7825000 0.0938834
1.7925001 0.1014052
1.8025001 0.1107717
1.8125001 0.1106072
1.8225001 0.1032858
1.8325001 0.0967231
1.8425001 0.1072746
So, I call the command to show me all graphs on the GUI
xmgrace 1.xvg rmsd_amber_2.xvg rmsd_3.xvg
Is it possible to automatically use the filenames as the labels for the legend, using an option found within the GUI of xmgrace? So far xmgrace automatically uses different line colors for each data series, but does not show the filename as the data label.
If this is not possible, please suggest me another GUI software for Linux which is able to open xvg files from the terminal for its visualization "on the fly".
Thanks !
Xmgrace does not do what you want
The xmgrace help (shown by calling xmgrace --help at the terminal) shows that there is no command line flag to specify data set legend titles. If that were the case you could probably come up with some bash commands to parse the title from your data files.
But there is another way
As an alternative, you can load a parameters file containing the correct titles. If you save any parameters file from within the xmgrace GUI and load it in a text editor, you will see that almost every aspect of Plot, Graph and Set appearance properties can be controlled.
However, it is not all needed; we can delete almost all of that information and just keep the lines related to our data set legend titles (everything else will just take the default values).
Solution
A minimal parameter file "template.par" might contain just the following four lines:
with g0
s0 legend "title0"
s1 legend "title1"
s2 legend "title2"
where in your case "title1" would be "RMSD".
You can then use xmgrace -param template.par 1.xvg rmsd_amber_2.xvg rmsd_3.xvg to create the plot.
Automating it
So far so good, but you want to create template.par automatically by parsing your chosen bunch of .xvg files. You could probably achieve this in any number of different ways using a bash script or even a bash one-liner.

How to convert image to table

I have an image of a table (in my case .gif) and want to extract the table it was (ideally, .ods).
Is there any way to do so? (doing it manually is discarted, since the table has more than 1000 rows and 6 columns)
Here is a part of the image / table:
You will be able to get most of it through OCR, but you'll need to manually verify the data and fix some inaccuracies that will be there. It definitely won't be perfect.
First thing to do is to ensure you have a good quality image for the OCR software:
Here's what I did with your sample png (I'm using Windows):
I opened the image in The Gimp.
Removed the orange/blue backgrounds:
a) Select -> By Color and clicked the blue background
b) I held down Shift and clicked the orange background (this will add it to the current selection)
c) Edit -> Fill With BG Color (this sets it to white)
d) Ctrl-Shift-A to cancel the selection
I removed the partially cut off '305' line:
a) used the Rectangular Select tool button from the palette, and filled the selection with BG Color, as above
Let's remove the table border:
a) Click the 'Fuzzy Select' tool button from the palette
b) Click somewhere on the table border (you should see the 'marching ants' instead of the border)
c) Edit -> Fill With BG Color
d) Ctrl-Shift-A to cancel the selection again
We need to increase the number of pixels that the numbers use so that the OCR can better detect their shapes
a) Image -> Scale Image. I chose to scale by 1000% with Linear Interpolation (the other interpolations won't work as well)
Download and install Tesseract from GitHub
a) At the command prompt type (include the double-quotes to cope with spaces within the path, & change your paths as necessary):
"D:\Program Files (x86)\Tesseract-OCR\tesseract" "d:\temp\your_image.png" "d:\temp\your_txt_file_output"
The output with be a text file with an appended .txt extension. It will still have a few artifacts but we can easily correct those in Notepad++ (or similar):
a) The commas were seen as full-stops, so I did a Find and Replace of "." with "," (I'm assuming you don't have any decimal points in the data!)
b) There were some spaces before a few commas, so I did Find and Replace " ," with "," (note I included a space before the comma in the Find)
c) There were still some spaces in the numbers, so I did a Find and Replace of " " with "" (a space with an empty replace)
This gave the following result:
298 299 300 301 302 303 304
910,820,000 920,820,000 930,820,000 941,820,000
952,820,000 983,820,000 9?4,820,000 210,000
220,000 220,000 220,000 220,000 220,000
220,000 2,500 2,500 3,000 3,000
3,000 3,000 3,000 19,000 19,000
20,000 20,000 20,000 20,000 20,000
Note the question mark in the place of 7 in the second block of text. Things like that still need to be tidied up.
Lastly, you'd copy and paste the rows of text into your spreadsheet etc.
I wanted to post another option I finally found online.
https://convertio.co/es/ocr/
Even though I think K Scandrett answer deserves to be the correct one, since it doesn't rely on a URL, which might go down.
If this is a one-time/rare need and you are windows OS user and you have a Microsoft Excel installed, the application supports extracting the image data to excel. Follow this link for the complete reference.

How to create floating figures in reStructuredText / Sphinx?

I want to have a figure with text wrapped around it.
This is what I'm saying:
Installation of Optional Accessories
====================================
.. warning:: Never plug in or unplug a Hand Robot or a Grasp Sensor while the robot is turned on, as the system will not function properly and damage to the robot could occur.
Installing a Hand Robot
-----------------------
.. _`fig-attach-hand-robot`:
.. figure:: attach-hand-robot.*
:scale: 40%
:align: right
Attach Hand Robot
Make sure the robot is turned off as described in the section :ref:`turn-off-robot`.
Take the hand robot out of the grounded bin that sits on top of the electrical panel (if you have an adjustable height table) or sits on top of the rear table (if you have a fixed height table). Make sure not to touch the pins on the electrical wiring while doing so. Insert the conical protrusion of the hand robot into the conical receptacle (see :ref:`fig-attach-hand-robot`). Once the hand robot is supported by the InMotion Arm Robot, make sure the two knobs below the Hand Robot have engaged and sprung in. If they have not, twist them until they do as shown (see :ref:`fig-knobs-in`).
and this screenshot of PDF output is what I'm getting.
Why is the figure caption centered, rather than under the image?
Why isn't the body text ("Make sure ..." and "Take the ...") on the LEFT of the image, rather than underneath it? I want the figure to float right and have the text on its left.
I have found that figures float to the side with :figwidth: and :align: specified. (Using the readthedocs theme.)
.. figure:: images/myimage.jpg
:figwidth: 40%
:align: right
https://docutils.sourceforge.io/docs/ref/rst/directives.html#figure
So, I did some research into reStructuredText and it seems what you want is not actually possible.
The documentation for the figure and the image directives never mention the ability to wrap text around the object.
This might be a feature request to provide to the Sphinx developers although I suspect they'll reject it because it isn't explicitly mentioned in the rst specification.
I was hoping the bounty would garner this some attention but I suspect is hasn't.
Though it is too late but maybe the answer would help future people.
You can use the sidebar directive to put the image.
.. sidebar:: mandatory_title. Use can use image caption here
.. Figure:: 1.png
In order to deal with images as they were part of the text you may actually use substitutions.
Here an extract from the documentation that can be helpful:
The |biohazard| symbol must be used on containers used to
dispose of medical waste.
.. |biohazard| image:: biohazard.png
I hope this helps
If anyone else runs into this problem then this bit of code might be a help. I decided that I didn't want to hack the actual sphinx code so I made a very short python script applied to the generated _build/latex/pi3d_book.tex to convert the \includegraphics that had \hfill before or after into wrapped images. There will be lots of things that stop this working such as putting images inside lists or scaling images. The sphinx directives in my rst are like
.. image:: perspective.png
:align: right
You obviously have to change the file names and paths to suit your setup. From my spinx project I run
$ make latexpdf
$ python wrapfix.py # or whatever you call this file
program listing of wrapfix.py
import subprocess
with open("_build/latex/pi3d_book.tex", "r") as f:
tx = f.read().splitlines()
txnew = []
flg1 = True
for line in tx:
if line == "" and flg1:
txnew += ["\\usepackage{wrapfig}",""]
flg1 = False # just do this once before first blank line
elif "includegraphics{" in line and "hfill" in line:
fname = line.split("{")[2].split("}")[0]
if line.startswith("{\\hfill"): # i.e. right justify
fl_type = "R"
else:
fl_type = "L"
txnew += ["\\begin{wrapfigure}{" + fl_type + "}{0.35\\textwidth}",
"\\includegraphics[width = 0.3\\textwidth]{" + fname + "}",
"\\end{wrapfigure}"]
else:
txnew += [line]
txnew = "\n".join(txnew)
with open("_build/latex/pi3d_book.tex", "w") as fo:
fo.write(txnew)
subprocess.Popen(["pdflatex", "pi3d_book"], cwd="/home/jill/pi3d_book/_build/latex")

Resources