Center image in overleaf with margins instead of text - image

I'm trying to center an image in the middle of the page in overleaf, but all the centering functions I can find only seem to center it in terms of the text, not the margins of the whole document. Is there a way to align an image to the center of the page, not aligned with the text? It ends up being a bit skewed to the right as is.
Here is the code for inserting my image:
\begin{figure}[H]
\centering
\includegraphics[width=1.1\textwidth, height = 1.5cm]{s_TTCD_data.png}
\caption{Tongue tip constriction location (TTCL) data for /s/.}
\end{figure}
I've also tried this, with the same result:
\begin{center}
\begin{figure}[H]
\includegraphics[width=1.1\textwidth, height = 1.5cm]{s_TTCD_data.png}
\caption{Tongue tip constriction location (TTCL) data for /s/.}
\end{figure}
\end{center}

Try:
\begin{figure}[H]
\centerline{\includegraphics[width=1.1\textwidth, height = 1.5cm]{s_TTCD_data.png}}
\caption{Tongue tip constriction location (TTCL) data for /s/.}
\end{figure}

Related

Remove any spacing, padding, and margin so a cell is filled completely with iText 7

How do I make a table in iText 7 with cells that don't have any spacing, padding, or margins on the inside. When I put an image in the cell it needs to fill the cell to 100%, touching the borders without any space of any kind at all.
I tried adding this to my Cell:
Cell qrImageCell = new Cell();
qrImageCell.setMargin(0f);
qrImageCell.setPadding(0f);
qrImageCell.setHeight(44f);
qrImageCell.add(barcodeImage.setMargins(0f,0f,0f,0f).setPadding(0f));
I also tried setting it in the table itself:
table.setPadding(0f);
table.setMargin(0f);
But whatever I try there is always a white rectangular area between the QR Code and the border (FYI: I would of course remove the border once it works.
Test with iText 7.1.15
With this image:
And this code:
Table table = new Table(1);
Image barcodeImage = new Image(ImageDataFactory.create("image.png"));
Cell qrImageCell = new Cell();
qrImageCell.setBorder(new SolidBorder(ColorConstants.RED, 2));
qrImageCell.setPadding(0f);
qrImageCell.add(barcodeImage);
table.addCell(qrImageCell);
doc.add(table);
The resulting output is:
Potential causes
Incorrect height
You have qrImageCell.setHeight(44f) in your code. Maybe that height does not correspond correctly with the height of your image. It's unlikely though that this is the problem, because it would not increase the width of the cell.
Impact of other cells
Making the table of the test above a 2-column table and adding a few cells shows that the size of the cells in the same row and column will have an impact on the size of the cell.
table.addCell(new Cell().add(new Paragraph("cell (1,2)")).setHeight(300));
table.addCell(new Cell().add(new Paragraph("cell (2,1)")).setWidth(300));
table.addCell(new Cell().add(new Paragraph("cell (2,2)")));
It's also unlikely that this is the problem, because in your output the image is centered in the cell.
There is no white space
Maybe the white "margins" are simply part of your barcode image. In that case, there isn't any spacing, margin or padding, but it would visually seem so.
Verify your input image or set a background color for the cell, so you can verify whether the white area is part of the image or part of the cell: qrImageCell.setBackgroundColor(ColorConstants.GREEN)
In the end the backgroundcolor trick helped me a lot. In the end the QR Image which is also generated by iText7 for some reason has a white border around itself. It's generated by this code:
BarcodeQRCode qrCode = new BarcodeQRCode(text);
PdfFormXObject barcodeObject = qrCode.createFormXObject(ColorConstants.BLACK, pdfDoc);
Image barcodeImage = new Image(barcodeObject).setPadding(0f).scaleAbsolute(44f, 44f)
But indeed setting the padding to "0f" removes any padding in the cell. Just have to find out if there's a possibility to remove that border around the QR code.

d3.tree scrollbar instead of panning

I have a tree width d3.js. when tree overflows svg, it is hidden and I can view hidden parts by panning on tree. is there any way to add scrollbar for view hidden parts instead of panning?
for example in this sample http://bl.ocks.org/robschmuecker/7880033 I want to add scroll bar to this tree. this sample is not what I want: https://bl.ocks.org/CrandellWS/ca7e6626c9e6b1413963
because in this example when we collapse nodes, scrollbar size not change.
You can get the svg bounding box using svg.getBBox(), where svg is your svg node, e.g.
let svg = document.getElementsByTagName("svg")[0];
let box = svg.getBBox()
and then use box.x, .y, .width and .height to calculate the correct viewBox attribute value, width and height.

How to expand the pixel coordinates in matlab?

I want develop an matlab's application that can show the bounding box to the object in the image.
I have detected the object, and cropped it.
And now, for the boundng box, i just have to add 10 in all my pixel.
For exmpl:
x=x+10;
y=y+10;
w=w+10;
h=h+10;
I use imcrop function.
But the problem is that i dont understand how to get the pixel's coordinates from imcrop.
[I_crop, I_rect]=imcrop(ImSeq(:,:,1),[])
I_rect=floor(I_rect);
final_rect=I_rect;
for t=1:NumImages
cur_r=final_rect(2);
cur_c=final_rect(1);
for r= cur_r -10:cur_r+10
for c=cur_c-10:cur_c+10
temp= abs(I_crop-ImSeq(r:r+I_rect(4),c:c+I_rect(3),t));
what is final_rect(2), final_rect(1), I_rect(4) and I_rect(3)?
How i can get the coordinates of x,y,w,h of the cropped image??
Thanks
In [I2 rect] = imcrop(I), rect is the cropping rectangle, a four-element position vector. Within the original image, the cropped area is defined by:
rect(2) the current row
rect(1) the current column
rect(3) is the width
rect(4) the height.

Mapping image into cylinder or sphere shape?

So lets say I have black & white image that is read with imread() command and saved into matrix A.
I want to output/graph this matrix A image in a cylinder shape. I know how to draw a cylinder in MATLAB, but I do not have a clue what I should do if I want to put image on a cylinder or draw image in cylinder shape. Any help will be appreciated. Thank you.
I found this site from googling.
http://www.flashandmath.com/advanced/rolls/cylin.html
This is exactly what I want to do, but I need to do this in MATLAB.
The technique is called texture mapping. This is a code example from surface function (R2011b):
load clown
surface(peaks,flipud(X),...
'FaceColor','texturemap',...
'EdgeColor','none',...
'CDataMapping','direct')
colormap(map)
view(-35,45)
This example loads RGB image from "peppers.png" and maps it onto cylinder:
imgRGB = imread('peppers.png');
[imgInd,map] = rgb2ind(imgRGB,256);
[imgIndRows,imgIndCols] = size(imgInd);
[X,Y,Z] = cylinder(imgIndRows,imgIndCols);
surface(X,Y,Z,flipud(imgInd),...
'FaceColor','texturemap',...
'EdgeColor','none',...
'CDataMapping','direct')
colormap(map)
view(-35,45)
Things are even simpler with the warp function (comes with Image Processing toolbox) as natan suggested:
imgRGB = imread('peppers.png');
[imgRows,imgCols,imgPlanes] = size(imgRGB);
[X,Y,Z] = cylinder(imgRows,imgCols);
warp(X,Y,Z,imgRGB);

How to insert a full-page letter-size image?

I have been trying to insert a letter-size image, but either this is cut because of the margins definition of the document style (book), or its size is limited to the specified margins.
Below is the code with which I have managed to obtain the size of the image:
...
\newenvironment{pagportada}{
\begin{list}{}{
\setlength{\hoffset}{-1in}
\setlength{\oddsidemargin}{0cm}
\setlength{\evensidemargin}{0cm}
\setlength{\leftmargin}{-1in}
\setlength{\rightmargin}{-1in}
\setlength{\textwidth}{14.3cm}
\setlength{\voffset}{-1in}
\setlength{\topmargin}{0.5cm}
\setlength{\headheight}{0pt}
\setlength{\topsep}{0pt}
\setlength{\headsep}{0pt}
\setlength{\topskip}{0pt}
\setlength{\footskip}{0pt}
\setlength{\textheight}{19.2cm}
%\setlength{\listparindent}{\parindent}
%\setlength{\itemindent}{\parindent}
%\setlength{\parsep}{\parskip}
}\item[]}
{\end{list}}
... and then call the environment to insert the figure as:
\begin{pagportada}
\includegraphics[width=\textwidth]{Portada}
\end{pagportada}
\newpage
If you are using LaTeX:
\usepackage{eso-pic}
The eso-pic package will help you put objects on the background of pages. This will not respect margins: which is your need.
To put an image, include the following code on your page:
% First page
...
\newpage
% Second page
\AddToShipoutPicture{
\put(0,0){
\parbox[b][\paperheight]{\paperwidth}{
\vfill
\centering
\includegraphics[width=\paperwidth,height=\paperheight,
keepaspectratio]{Portada}
\vfill
}
}
}
\newpage
And the image is put at (0,0) page-coordinates and stretched (maintaining aspect ratio) onto the whole page, middle centred.
(not tested)

Resources