wide and long table in latex - latex

I am using a wide and long table. I am not sure how to put it in my thesis. Since it is wide, sidewaystable may be the choice. Meanwhile it is also too long to fit in one page, so longtable comes into my mind. However, I cannot make sidewaystable and longtable working together for one table, e.g.
\begin{sidewaystable}
\begin{longtable}{| c ||c| c| c |c| c|| c |c| c|c|c| }
\caption{A glance of images.}
\centering
% table content
\end{longtable}
\end{sidewaystable}
What shall I do?

Use lscape package with longtable or supertabular.

use a p{width} in place of l,r, or c in your column declaration, like this:
\begin{longtable}{ | p{0.2\textwidth} | p{0.5\textwidth | }
Then, to keep your content centered, add a >{\centering} before the p{width}, like this:
\begin{longtable}{ | >{\centering}p{0.2\textwidth} | >{\centering}p{0.5\textwidth | }

Related

How to automatic break lines in latex?

I have searched but nothing useless, only "use \newline" or "use \".
I'm creating a simple latex document to store any texts instead of using .txt, and the problem is that the pdf document contains the lines going towards right until they go out of the paper.
I'm using this simple code
\documentclass[a4paper]{article}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
left=5mm,
top=20mm,
}
\begin{document}
\section{Text 1}
Loremipsumdolorsitamet,consecteturadipiscingelit,seddoeiusmodtemporincididuntutlabore etdoloremagnaaliqua.Utenimadminimveniam,quisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequat.Duisauteiruredolorinreprehenderitinvoluptatevelitessecillum doloreeufugiatnullapariatur.Excepteursintoccaecatcupidatatnonproident,suntinculpaquiofficiadeseruntmollitanimidestlaborum.
\end{document}
Since latex sees it as a one word, it refuses to break it since it doenst know its hyphenation. But I would like to allow latex to break it regardless. Any thoughts ?
Remarks: I already have used:
\hspace{0pt}
\leavevmode\nobreak\hspace{0pt}
\mbox{Loremip...larorum.}
Nothing worked.
I think I got why nothing worked. See my code below, that I managed to compile successfully after editing your MWE.
You basically have two ways to force hyphenation here.
As in the comment by SamCarter, you manually split words within text, just using \- where necessary. I did it below in line 18 (6 from bottom).
You add to your preamble the command \hyphenation{word-to-split}: I did this below to hyphenate the word in line 20 (4 from bottom). Notice that, in this case, you use - instead of \- within the braces {} enclosing the argument.
\documentclass[a4paper]{article}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
left=5mm,
top=20mm,
}
\hyphenation{Duisauteiruredolorinre-prehenderitinvoluptatevelitesse-cillum doloreeufugiatnullapariatur}
\begin{document}
\section{Text 1}
Loremipsumdolorsitamet, consecteturadipiscingelit,
seddoeiusmodtemporincididuntutlaboreetdoloremagna.
Uten\-imadminimveniam,
quisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequat.
Duisauteiruredolorinreprehenderitinvoluptatevelitessecillumdoloreeufugiatnullapariatur.
Excepteursintoccaecatcupidatatnonproident,
suntinculpaquiofficiadeseruntmollitanimidestlaborum.
\end{document}
Finally, if the full stop character . is not followed by a space, two separate words may be interpreted as one and the command \hyphenation may not work as expected. Not sure that this was the detail making you write that nothing worked, but be careful to this too.

I was wondering how to create several rows in a box using the fbox command in latex

This is a very basic question, but I cant find the answer to this question....
I would like to create a box that looks like:
___________________
|hello1 |
|hello2 |
|hello3 |
|__________________|
I have tried the fbox command in Latex. However I only get the text on one line and not several.
\fbox puts a frame round its content, but is not a paragraph box. So you need a \parbox inside an \fbox
\documentclass{article}
\begin{document}
\fbox{\parbox{\textwidth}{%
hello1\\
hello2\\
hello3
}}
\end{document}
Also, if you append \noindent before \fbox , i.e.
\documentclass{article}
\begin{document}
\noindent \fbox{\parbox{\textwidth}{%
hello1\\
hello2\\
hello3
}}
\end{document}
you can prevent indentation of the box.

Heading \subsection at start of framed environment in LaTeX without leading padding

I've got a framed environment of the memoir class with content like this:
\begin{framed}
\subsection{Article 1}
Content of Article 1
\subsection{Article 2}
Content: Article 2
\end{framed}
This renders in the following way:
._________________.
| | <-- superfluous whitespace
| Article 1 |
| Content of Art- |
| icle 1 |
| |
| Article 2 |
| Content: Artic- |
| le 2 |
.-----------------.
The \subsection{} is introducing the whitespace preceding itself, which I'd prefer not to be there inside this framed environment, though I do want such whitespace in regular text (i.e. outside the framed environment) and for subsections-after-the first one.
When inside the framed environment, I'd like to have formatting essentially like this:
._________________.
| Article 1 |
| Content of Art- |
| icle 1 |
| |
| Article 2 |
| Content: Artic- |
| le 2 |
.-----------------.
Any thoughts or suggestions as to how one may achieve this modification to headings at the beginning of the framed environment would be much appreciated.
Edit: Based on mkluwe's comments, I've rooted out the \subsection command in memoir.cls:
3314 \newcommand{\subsection}{%
3315 \subsechook%
3316 \#startsection{subsection}{2}% level 2
3317 {\subsecindent}% heading indent
3318 {\beforesubsecskip}% skip before the heading
3319 {\aftersubsecskip}% skip after the heading
3320 {\normalfont\subsecheadstyle}} % font
3321 \newcommand{\subsechook}{}
3322 \newcommand{\setsubsechook}[1]{\renewcommand{\subsechook}{#1}}
3323 \newlength{\subsecindent}
3324 \newcommand{\setsubsecindent}[1]{\setlength{\subsecindent}{#1}}
3325 \setsubsecindent{\z#}
3326 \newskip\beforesubsecskip
3327 \newcommand{\setbeforesubsecskip}[1]{\setlength{\beforesubsecskip}{#1}}
3328 \setbeforesubsecskip{-3.25ex \#plus -1ex \#minus -.2ex}
3329 \newskip\aftersubsecskip
3330 \newcommand{\setaftersubsecskip}[1]{\setlength{\aftersubsecskip}{#1}}
3331 \setaftersubsecskip{1.5ex \#plus .2ex}
So a corollary to my question above would seem to be: How can one refine this subsection command such that e.g. if it's the first element in an environment (such as the framed environment) its \beforesubsecskip is very small?
Thank you for reading.
Sincerely,
Brian
If it happens infrequently enough you could just use a vspace command as first entry inside each frame. You could even create a new frame environment to do it automatically. In any case you would need to tweak the vspace to take away the right amount of padding. As you want, the new environment below will remove padding for first subsection entry but not for the subsequent ones:
\newenvironment{subsectframe}{\begin{framed}\vspace{-1.0\baselineskip}}{\end{framed}}
\begin{document}
\begin{subsectframe}
\subsection{Article 1}
Content of Article 1
\subsection{Article 2}
Content: Article 2
\end{subsectframe}
\end{document}
I do understand that the problem is "with the subsection". However I think fixing it by creating a new environment is going to be cleaner solution than trying to alter the subsection command so it intelligently avoids adding space depending on where it is.
I don't know this environment, but in the documentation I find:
\FrameHeightAdjust: macro; height of frame above baseline at top of
page
You might try diddling that...
As a quick and dirty solution I copied the definition of the \subsection command from article.cls and deleted the vertical skip:
\documentclass{article}
\usepackage{framed}
\makeatletter
\newcommand\subsectionx{\#startsection{subsection}{2}{\z#}%
{0ex}%
{1.5ex \#plus .2ex}%
{\normalfont\large\bfseries}}
\makeatother
\begin{document}
\begin{framed}
\subsectionx{Article 1}
Content of Article 1
\subsection{Article 2}
Content: Article 2
\end{framed}
\end{document}

Controlling LaTeX column flow

What I'm trying to do: I have a page that consists of pairs of two sentences each. The pairs are separated by a whole line break. My problem is that when I have an odd number of pairs, the second sentence will automatically be placed on the next column.
How can I use LaTeX to make block structures that multicol does not ignore, to keep the two sentences together? If there's better code to solve this problem, or a better column implementation (though I don't believe I can use \twocolumn in the document declaration), please post it.
My current code:
\documentclass{article}
\usepackage{fullpage}
\usepackage{multicol}
\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
\newcommand{\pair}[2]{
\emph{#1}\\*
#2
}
\begin{document}
\begin{multicols}{2}
\pair{Sentence 1.}{Sentence 2.}
\pair{Sentence 2 (pair 2).}{Sentence 2 (pair 2).}
\pair{The last pair, first sentence.}{Last sentence.}
\end{multicols}
\end{document}
This generates: http://img541.imageshack.us/img541/3444/columns.png . The second pair is what I am trying to avoid.
Try this:
\newcommand{\pair}[2]{%
\parbox{\hsize}{\emph{#1}\\*#2}\par}

Can you iterate in LaTeX?

I'm new to LaTeX and I must say that I am really struggling with it. I discovered the \newcommand command that is kind of like a function/method in regular programming languages. You can give it arguments and everything.
I was wondering though, can I somehow iterate in LaTeX? Basically, what I would like to do is create a table with N+1 columns where the first row just contains a blank cell and then the numbers 1, 2, ..., N in the other columns. I only want to give N as an argument to this 'function' (newcommand).
Here is an example of something that might look like what I'm looking for (although obviously this won't work):
\newcommand{\mytable}[2]{
\begin{tabular}{l|*{#1}{c|}} % table with first argument+1 columns
for(int i = 1; i <= #1; i++) "& i" % 'output' numbers in different columns
\\\hline
letters & #2 % second argument should contain actual content for row
\\\hline
\end{tabular}
}
Call it with:
\mytable{3}{a & b & c}
Output should be:
| 1 | 2 | 3 |
--------+---+---+---+
letters | a | b | c |
--------+---+---+---+
Does anyone know if something like this is possible?
Thanks!
Just make the following into a new command and be sure to use package ifthen.
\begin{tabular}{l|*{10}{c|}}
\newcounter{count}
\whiledo{\value{count}<10}{
\ifthenelse{\value{count}=0}{}{\the\value{count}}
\ifthenelse{\value{count}<9}{&}{\\}
\stepcounter{count}
}
letters&a&b&c&d&e&f&g&h&i\\
\end{tabular}
Auntie Google says yes.
You can use the \loop or \repeat tokens. Or the multido package.
Sure it's possible. You can also recur. eplain has iteration macros in it, see, eg, here.
Another possibility (if you're lazy like me) is perltex

Resources