\documentclass[10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\usepackage{multicol}
\usepackage{geometry}
\geometry{
total={272mm,394mm},
left=20mm,
right=20mm,
top=20mm,
bottom=20mm
}
\setlength{\columnsep}{1cm}
\setlength{\columnseprule}{0.3mm}
\title{Test}
\date{}
\begin{document}
\maketitle
\begin{multicols}{2}
[
\flushleft{\rule{176mm}{0.3mm}}
]
\blindtext[10]
\end{multicols}
\end{document}
I have tried to make a 'T' shaped divider for a document, but it seems like multicols doesn't support a horizontal line above the columns.
I tried to simulate this effect by using
\flushleft{\rule{176mm}{0.3mm}}
but this doesn't help me out.
Is there any way to erase the gap between the two dividers? or is there a different way to make a 'T' shaped divider?
Also, im curious why the the horizontal length of the \rule is 176mm. the width of the paper is 272mm and the margins in the left and right are 20mm each, so why is the length 176mm instead of 232mm?
You could place your horizontal line before the multicols:
\documentclass[10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\usepackage{multicol}
\usepackage{geometry}
\geometry{
% total={272mm,394mm},
left=20mm,
right=20mm,
top=20mm,
bottom=20mm
}
\setlength{\columnsep}{1cm}
\setlength{\columnseprule}{0.3mm}
\title{Test}
\date{}
\begin{document}
\maketitle
\noindent\rule{\textwidth}{0.3mm}
\vspace*{-0.5cm}
\begin{multicols}{2}
\blindtext[10]
\end{multicols}
\end{document}
I wrote a script to convert the EELS map to EELS line scan data, and it works well with DM 2.0. I can deal with it as directly collected EELS line scan data with DM2.0. But it does not work with DM 3.0 and the above version. It looks DM 3.0 still recognizes it as an EELS map file. DM3.0 still tried to generate elemental maps with multiple windows from it not generate line scan profiles with one single window and said the display type is incorrect. Not sure what code/command I need to add to fit the DM 3.0 and above versions. Appreciate any suggestions/comments.
image source
source := getFrontImage()
number sizeX,sizeY,sizeZ
source.Get3Dsize(sizeX,sizeY,sizeZ)
Result( "Original size:"+ sizeX +"; "+ sizeY+"; "+sizeZ+""+"\n" )
image sum
number regionsizeX = 1
number regionsizeY = sizeY
number row,col
Result( "new size:"+ regionsizeX +"; "+ regionsizeY+"; "+row+""+row+" "+"\n" )
sum := RealImage("Line Scan of [0,0,"+regionSizeY+","+regionSizeX+"]",4,sizeX/regionSizeX,sizey/regionsizeY,sizeZ)
//sum := ImageClone(source)
sum = 0
for (row=0;row<regionsizeY;row++) for (col=0;col<regionSizeX;col++)
{
OpenAndSetProgressWindow("Doing sub-block","x = "+col," y = "+row)
sum += Slice3(source,col,row,0,0,sizeX/regionSizeX,regionsizeX,1,sizeY/regionSizeY,regionSizeY,2,sizez,1)
}
OpenAndSetProgressWindow("","","")
ImageCopyCalibrationFrom(sum, source)
sum.setdisplaytype (1)
sum.SetStringNote( "Meta Data:Format", "Spectrum image" )
sum.SetStringNote( "Meta Data:Signal", "EELS" )
showimage(sum)
I'm also a bit confused by your terminology. When you write "Convert a Map into a LineScan" do you mean:
a) Convert a 3D Spectrum-Image (xy scan, one spectral dimension) into a 2D Line-Scan Spectrum-Image (one spatial dimension, one spectral dimension)
or
b) Convert a 2D Map (xy scan, one value) in a 1D Line-Trace (one spatial dimension, one value per point) ?
I suppose you mean a) and answer to that.
I'm surprised if/that your script would work without issues in GMS 2.
Your final (supposedly line-scan SI) data is still a 3D dataset with the dispersion running in Z-direction. This is not the typical LineScan SI data format (which is dispersion in X, spatial dimension in Y, no Z dimension).
Am I right in thinking that you want to "collapse" your 3D data along the y-dimension (by summing) ?
If so, what you want to do is:
// Get Input
image src3D := GetFrontImage()
number sizeX,sizeY,sizeZ
if ( 3 != src3D.ImageGetNumDimensions() ) Throw( "Input not 3D")
src3D.Get3Dsize(sizeX,sizeY,sizeZ)
// Optional: Use Rect-ROI on image to specify area
// If no selection, will return full FOV
number t,l,b,r
src3D.GetSelection(t,l,b,r)
// Prepare output (for summing 3D of rect-selection along y)
// NB: 2D container has:
// X dimension (spatial) along Y
// Z dimension (energy) along X
number nSpatial = r - l
number nSpectral = sizeZ
number eOrig, eScale, sOrig, sScale
string eUnit, sUnit
src3D.ImageGetDimensionCalibration(0, sOrig, sScale, sUnit, 0)
src3D.ImageGetDimensionCalibration(2, eOrig, eScale, eUnit, 0)
string name
if ( nSpatial != sizeX )
name = "Y-projection of [" + t + "," + l + "," + b + "," + r + "] over " + (b-t) + " rows"
else
name = "Y-projection over " + sizeY + " rows"
image dst2D := RealImage( name, 4, nSpectral, nSpatial )
dst2D.ImageSetDimensionCalibration(0, eOrig, eScale, eUnit, 0)
dst2D.ImageSetDimensionCalibration(1, sOrig, sScale, sUnit, 0)
// Copy Tags (contains necessary meta tags! Meta Data Format & Signal)
dst2D.ImageGetTagGroup().TagGroupCopyTagsFrom( src3D.ImageGetTagGroup() )
// Display (with captions)
dst2D.ShowImage()
dst2D.ImageGetImageDisplay(0).ImageDisplaySetCaptionOn(1)
number doFAST = 0
if ( !doFAST )
{
// Perform actuall summing (projection) by summing "line by line"
// into the LinePlot SI. Note the flipping of input and output dimensions!
for( number y = t; y<b; y++ )
{
number lineNumber = y - t
dst2D.slice2( 0,0,0, 0,nSpectral,1, 1,nSpatial,1 ) += src3D.slice2( l,y,0, 2,nSpectral,1, 0,nSpatial,1)
}
}
else
{
// Alternative (faster) projection. Use dedicated projection command.
image proj := src3D[l,t,0,r,b,nSpectral].Project(1) // Outcome of projectsion is having x=x and y=z, so need flip axis
dst2D = proj.slice2(0,0,0, 1,nSpectral,1, 0,nSpatial,1 ) // Flip axis
}
// Display (with captions)
dst2D.ShowImage()
dst2D.ImageGetImageDisplay(0).ImageDisplaySetCaptionOn(1)
Note that iterating using slice blocks is fast, but not as fast as the dedicated 'Project' command available in latest GMS versions. The example uses either, but lines #51-56 might not be available in older GMS.
Edit to address comment below:
Other relevant meta data for spectra is also found in the tags. For EELS, in particular the collection & convergence angle as well as the HT is of importance. You can find out about the tag-path by checking the tags of a properly acquired EELS spectrum.
Or, you can find out about their tag-paths by "converting" an empty 1D line-plot into an EELS spectrum and then attempting a quantification. You will get the prompt to fill in the data. After doing so, check the tags of the image:
I have an Rnw file with a table using the kable command. I want the table to be displayed in line with the text that it follows. How can I stop the table from being displayed at the top of the page? This is the Rnw code:
\documentclass{article}
\begin{document}
Here is my data, which is supposed to be below this sentence.
\\
\begin{abstract}
<<>>=
a <- 1; b <-2; c <-3; d <- 4
df.mse <- data.frame(row.names = c("Normal model", "Laplace model"))
df.mse["Normal model", "Normal MLE"] <- a
df.mse["Normal model", "Laplace MLE"] <- b
df.mse["Laplace model", "Normal MLE"] <- c
df.mse["Laplace model", "Laplace MLE"] <-d
library(knitr)
kable(df.mse, caption="approximate MSE for each model/estimator combination")
#
\end{abstract}
\end{document}
I'd prefer for the solution to not involve changing the actual Tex file, as I'd like to carry on working on the Sweave file without worrying about overriding the solution. I know you can use the float package in LaTeX but I'm not sure how to do that in the context of a Sweave file.
Don't include a caption in the call to kable. Then it will just output a tabular environment without wrapping it in a table float. If the caption is not required, that simply means leaving out the caption argument in your call to kable.
If you do want a caption, but want the table placed inline, you need to start your table with \begin{table}[h]. You can put that in the Rnw file like this:
<<>>=
a <- 1; b <-2; c <-3; d <- 4
df.mse <- data.frame(row.names = c("Normal model", "Laplace model"))
df.mse["Normal model", "Normal MLE"] <- a
df.mse["Normal model", "Laplace MLE"] <- b
df.mse["Laplace model", "Normal MLE"] <- c
df.mse["Laplace model", "Laplace MLE"] <-d
library(knitr)
#
\begin{table}[h]
\caption{This is the caption.}
<<echo=FALSE>>=
kable(df.mse)
#
\end{table}
If I write a simple Rnw document containing a figure like e.g.,
\documentclass[11pt]{article}
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<<setup, include=FALSE, cache=FALSE>>=
opts_chunk$set(dev = "pdf", comment = NA, fig.path = "figure/", fig.align='center', cache=FALSE, message=FALSE, background='white')
options(replace.assign=TRUE,width=85, digits = 8)
knit_hooks$set(fig=function(before, options, envir){if (before) par(mar=c(4,4,.1,.1),cex.lab=.95,cex.axis=.9,mgp=c(2,.7,0),tcl=-.3)})
#
<<prepare-data, include=FALSE>>=
#
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{document}
A simple plot
\begin{figure}
<< scat, echo = FALSE, fig.width = 4.5, fig.height=3>>=
plot(runif(10), runif(10), pch = 20)
#
\end{figure}
\end{document}
Why does knitr create a PDF file with the filename figure/scat-1.pdf instead of figure/scat.pdf?
The reason was explained in the v1.7 release notes. In the development version (to be v1.8), you can use fig_chunk() to obtain the figure filenames (see package NEWS). Also see a related discussion here.
I'm downloading hex color from web and when I try to convert it to RGB it's not working.
I'm using this function:
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
I think the problem is that when I get value from internet (for example 000) when I convert it to int so I can pass it as argument to function above, int is represented just as 0 so function doesn't recognize the color. Same thing for example with 090 when in int its 90.
You need to think of the hex colour as a string and process each component separately.
The colour #3B9 has digits "3" "B" and "9"
However, looking here you will see that for 3 digit representation, characters are doubled.
So in this case the colour is actually #33BB99:
red = 3*16+3 = 51
green = 11*16+11 = 187
blue = 8*16+8 = 136
alpha = 255
So the colour '#3B9' would become:
[51/255.0, 187/255.0, 136/255.0, 1.0]
So you should first determine if the string is representing colours in a compressed way and duplicate digits if necessary. Then convert the pairs of digits to their decimal value and then convert to UIColor.
Hope that helps, and I hope my calculations are correct. I am not good with objective-C so I wont provide code, but it should be easy enough to write your own function, although I would bet that function already exists somewhere.