I have a problem to insert multiple SVG pictures in a table. I try many ways with tabular but I don't have any succes.
I manage to implement a single picture in the document with this piece of code, using the inkscape method:
\begin{figure}[h!]
\centering
\def\svgwidth{5cm}
\input{SupplyChain.pdf_tex}
\end{figure}
I would like a table with 3 rows and 2 columns. The first column contains the picture and the second its description.
You can use the same code in a tabular:
\documentclass{article}
\usepackage{graphicx}
\begin{document}
{
\begin{tabular}{cc}
\def\svgwidth{5cm}
\input{test.pdf_tex}
&
text\\
\def\svgwidth{5cm}
\input{test.pdf_tex}
&
text\\
\def\svgwidth{5cm}
\input{test.pdf_tex}
&
text\\
\end{tabular}
\end{document}
Related
I have a chart in Excel with the Title linked to a cell =REPORT_PAGE!$A$1
The formula in A1 looks like this:
=ProductName & ": Project Performance" & CHAR(10) &
"SPI: " & TEXT(VLOOKUP(TODAY(),ProjectData,13,TRUE),"0#.0#") & CHAR(10) &
"EV: " & TEXT(VLOOKUP(TODAY(),ProjectData,11,TRUE),"#.0#%") & CHAR(10) &
"PV: " & TEXT(VLOOKUP(TODAY(),ProjectData,12,TRUE),"#.0#%")
This provides a Title which is all the same size; something like this:
BIG CHART TITLE
BIG METRIC 1
BIG METRIC 2
BIG METRIC 3
I need something that can change the title to look more like this:
BIG CHART TITLE
small-font metric 1
small-font metric 2
small-font metric 3
I would like to do this without VBA if possible.
Check out Paste Picture Links
Create the title in 4 rows of cells
Format them as needed
Paste them as a picture link onto the chart where the title would go (do not use the actual title object in the chart.
Optional - Position the picture link where you want and group it with the chart so they move in unison.
I'm debugging some ColdFusion code (although the question is really language-agnostic), and from the debug output, have two columns of text.
Those columns are field name <tab> value and want to be able to quickly convert this into test code.
The text I start off with:
a 1
b 2
c 3
etc
The code I want to end up with:
structInsert(myStruct, "a", 1);
structInsert(myStruct, "b", 2);
structInsert(myStruct, "c", 3);
etc
Ordinarily, I'd use Excel, pasting the two columns of data into columns A and B, and create a formula in column C that concatenates A and B something like
="structInsert(myStruct, """ & A1 & """, " & B1 & ");"
This works fine (and is one of the main reasons I love Excel).
But I'm wondering... given that the whole world doesn't have Excel, how does everyone else do this?
Thanks!
Well I like to do with Notepad++ or Eclipse with search and replace feature with regular expression.
Like search for
([a-z]*)\t(\d)
replace with
structInsert(myStruct,"\1",\2);
So simple.. right?
You could do this with regular expressions.
In CFEclipse/CFBuilder open the Find/Replace dialogue
Find: ^(.+?)\t(.+?)$
Replace with: structInsert(myStruct, "$1", $2);
Check Regular Expressions
Click Replace All
I have a table of values (actually written in LaTeX markup) and I can select one column only using Ctrl+Q
For example,
% Select the second column only ....
1.75130211563 & 0.0299693961831 \\
1.72144412106 & 0.0181406611688 \\
1.92102386609 & 0.0247758598737 \\
1.56512790839 & 0.0137107006809 \\
1.75263937567 & 0.017155656704 \\
1.99501744437 & 0.39550649953 \\
1.96862597164 & 0.030198328601 \\
...
I'd like to reduce the number of decimal places of the selected numbers only (i.e. for each number selected I apply round(NUMBER * 100)/100 to get, for example, the number rounded to 2 decimal places). To do this, I need to first have a variable to refer to NUMBER (the number on that line) as well as replace the current selection with the output.
How do I do this?
Also if this isn't possible, I can copy the column into an actual spreadsheet program and edit it there, but how do I paste it back in place?
Update: I've accepted an answer. It isn't as neat as I had hoped, but it does make sense. Thanks!
Another update: To paste a column in from an external spreadsheet, paste the column into a :new buffer, select the data using Ctrl+Q and yank into a register. Move to the top line and appropriate column in the table of data and paste in with P.
Are you looking for this ?
:'<,'>s#\%V\d*\.\d\+#\=round(str2float(submatch(0))*100)/100#g
This seems to work:
:'<,'>:s/\d\+\.\d\+/\=printf("%.2f", str2float(submatch(0)))/
I.e. visually select the first column and issue the command above.
% Select the second column only ....
1.75 & 0.0299693961831 \\
1.72 & 0.0181406611688 \\
1.92 & 0.0247758598737 \\
1.57 & 0.0137107006809 \\
1.75 & 0.017155656704 \\
2.00 & 0.39550649953 \\
1.97 & 0.030198328601 \\
The question is similar to this one: How to display a content in two-column layout in LaTeX?
but about placing two tables side by side.
I have two small tables looking like that:
\begin{table}[t]
\begin{tabular}{|c|l||r|r||r|r|}
%content goes here
\end{tabular}
\caption{some caption}
\end{table}
\begin{table}[t]
\begin{tabular}{|c|l||r|r||r|r|}
%content goes here
\end{tabular}
\caption{some caption for second table}
\end{table}
I have one-column document and these tables are really narrow, so I would like to display them side by side (with separate captions) insted of one under another with a lot of unused, white space.
I tried to do it with this \multicols but it seems that floats (tables here) cannot be placed inside of it.
Any ideas?
EDIT
OK, I've done something like that:
\begin{table}[h]
\begin{minipage}[b]{80mm}
\begin{tabular}{|c|l||r|r||r|r|}
%//first table goes here
\end{tabular}
\caption{some caption for first table}
\end{minipage}
\begin{minipage}[b]{80mm}
\begin{tabular}{|c|l||r|r||r|r|}
%//second table goes here
\end{tabular}
\caption{some caption for second table}
\end{minipage}
\end{table}
But the table is always using as much space, as it needs, no matter what size of minipage I would set. For example, if I have 80 mm for minipage, the caption will be limited to these 80 mm but the table will be wider.
If I have two tables, and one table is just a little bit too wide, it would not apper next to first table, but underneath.
Is there any way to limit the table to specified width? Or to force them to appear one next to another? Or maybe how to change the font size just for one of the tables?
The reason your second table is going below the first table instead of right next to it is because of the space between the two minipages. You have to have the statements right below the other, otherwise latex would treat it like an end line. Took me about a week to figure this out for my own tables.
\end{minipage}
\begin{minipage}[b]{80mm}
Instead of:
\end{minipage}
\begin{minipage}[b]{80mm}
Use two minipages or two tabular environments in the same table environment (but then you'll have to do something about the captions if you need them).
Use the subfig package like this:
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[bf,small,tableposition=top]{caption}
\usepackage{subfig}
\begin{document}
\begin{table}
\centering
\subfloat[First table.]{%
\begin{tabular}{|c|l||r|r||r|r|}
a & b & c & d & e & f \\
a & b & c & d & e & f \\
\end{tabular}}%
\qquad\qquad% --- set horizontal distance between tables here
\subfloat[Second table.]{%
\begin{tabular}{|c|l||r|r||r|r|}
a & b & c & d & e & f \\
a & b & c & d & e & f \\
a & b & c & d & e & f \\
a & b & c & d & e & f \\
\end{tabular}}
\end{table}
\end{document}
This will take care of vertical alignment of the tables when they have a different number of rows like in this example. Notice also that tables have their captions above them, while figures have their caption below them. The excellent caption package can help you change that if you want.
Finally, you should take a look at the booktabs package for professional quality typesetting of tables. It asks you to avoid vertical lines and instead use horizontal lines. The result is normally much better, IMHO.
I am creating a report in LaTeX which involves a few tables. I'm stuck on that as my cell data in the table is exceeding the width of the page. Can I somehow wrap the text so that it falls into the next line in the same cell of the table?
Is it somehow related to the table's width? But as it's overshooting the page's width, will it make a difference?
Use p{width} for your column specifiers instead of l/r/c.
\begin{tabular}{|p{1cm}|p{3cm}|}
This text will be wrapped & Some more text \\
\end{tabular}
EDIT: (based on the comments)
\begin{table}[ht]
\centering
\begin{tabular}{p{0.35\linewidth} | p{0.6\linewidth}}
Column 1 & Column2 \\ \hline
This text will be wrapped & Some more text \\
Some text here & This text maybe wrapped here if its tooooo long \\
\end{tabular}
\caption{Caption}
\label{tab:my_label}
\end{table}
we get:
With the regular tabular environment, you want to use the p{width} column type, as marcog indicates. But that forces you to give explicit widths.
Another solution is the tabularx environment:
\usepackage{tabularx}
...
\begin{tabularx}{\linewidth}{ r X }
right-aligned foo & long long line of blah blah that will wrap when the table fills the column width\\
\end{tabularx}
All X columns get the same width. You can influence this by setting \hsize in the format declaration:
>{\setlength\hsize{.5\hsize}} X >{\setlength\hsize{1.5\hsize}} X
but then all the factors have to sum up to 1, I suppose (I took this from the LaTeX companion). There is also the package tabulary which will adjust column widths to balance row heights. For the details, you can get the documentation for each package with texdoc tabulary (in TeXlive).
Another option is to insert a minipage in each cell where text wrapping is desired, e.g.:
\begin{table}[H]
\begin{tabular}{l}
\begin{minipage}[t]{0.8\columnwidth}%
a very long line a very long line a very long line a very long line
a very long line a very long line a very long line a very long line
a very long line a very long line a very long line %
\end{minipage}\tabularnewline
\end{tabular}
\end{table}
I like the simplicity of tabulary package:
\usepackage{tabulary}
...
\begin{tabulary}{\linewidth}{LCL}
\hline
Short sentences & \# & Long sentences \\
\hline
This is short. & 173 & This is much loooooooonger, because there are many more words. \\
This is not shorter. & 317 & This is still loooooooonger, because there are many more words. \\
\hline
\end{tabulary}
In the example, you arrange the whole width of the table with respect to \textwidth. E.g 0.4 of it. Then the rest is automatically done by the package.
Most of the example is taken from http://en.wikibooks.org/wiki/LaTeX/Tables .
Simple like a piece of CAKE!
You can define a new column type like (L in this case) while maintaining the current alignment (c, r or l):
\documentclass{article}
\usepackage{array}
\newcolumntype{L}{>{\centering\arraybackslash}m{3cm}}
\begin{document}
\begin{table}
\begin{tabular}{|c|L|L|}
\hline
Title 1 & Title 2 & Title 3 \\
\hline
one-liner & multi-line and centered & \multicolumn{1}{m{3cm}|}{multi-line piece of text to show case a multi-line and justified cell} \\
\hline
apple & orange & banana \\
\hline
apple & orange & banana \\
\hline
\end{tabular}
\end{table}
\end{document}
If you want to wrap your text but maintain alignment then you can wrap that cell in a minipage or varwidth environment (varwidth comes from the varwidth package). Varwidth will be "as wide as it's contents but no wider than X". You can create a custom column type which acts like "p{xx}" but shrinks to fit by using
\newcolumntype{M}[1]{>{\begin{varwidth}[t]{#1}}l<{\end{varwidth}}}
which may require the array package. Then when you use something like \begin{tabular}{llM{2in}} the first two columns we be normal left-aligned and the third column will be normal left aligned but if it gets wider than 2in then the text will be wrapped.
To change the text AB into A \r B in a table cell, put this into the cell position: \makecell{A \\ B}.
Before doing that, you also need to include package makecell.
The new tabularray makes wrapping text in cells easier then ever before.
The package supports all the traditional used column names like c, l, r, etc., but also has its own Q column which accepts various keys to control the width and vertical and horizontal alignment. It also provides an X column, as known from tabularx` which will automatically calculate the width of the column to fit the table into the available text width.
Another nice feature is that all the settings can also be done for individual cells.
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{table}
\begin{tblr}{|c|Q[2cm,valign=m]|X[j,valign=m]|}
\hline
Title 1 & Title 2 & Title 3 \\
\hline
one-liner & multi-line text & multi-line piece of text to show case a multi-line and justified cell \\
\hline
apple & orange & banana \\
\hline
\SetCell{h,2cm} wrapping text only in a single cell & orange & banana \\
\hline
\end{tblr}
\end{table}
\end{document}
(thanks to Shayan Amani for providing a MWE in their answer!)
\begin{table}
\caption{ Example of force text wrap}
\begin{center}
\begin{tabular}{|c|c|}
\hline
cell 1 & cell 2 \\ \hline
cell 3 & cell 4 & & very big line that needs to be wrap. \\ \hline
cell 5 & cell 6 \\ \hline
\end{tabular}
\label{table:example}
\end{center}
\end{table}