Last-page column equalization for latex IEEEtran class? - latex

In the documentation for the IEEEtran LaTeX class, it's mentioned that the two columns on the last page need to be manually adjusted in order to be balanced (have the same length).
I see that \newpage will allow me to break the first column so the rest of the content is on the second column. This allows for paragraph-level equalization, and looks good, but I'm having trouble with line-level equalization, that is, breaking the column by lines instead of by paragraphs.
When I insert \newpage in the middle of a paragraph (instead of between paragraphs), LaTeX effectively splits the paragraph in two. The second part goes to the top of the second column (as desired) and the first part remains in the first column. There are two issues I've found with this, and I've only solved one of them.
The first issue is that the partial paragraph on the top of the second column is treated by LaTeX as a new paragraph, so it's indented. I fixed this by adding \noindent after \newpage so that it's not indented.
The second issue is that for the partial paragraph in the first column, the paragraph is justified (as expected), but the last line is ragged (no justification). Is there a way to force justification of this last line? LaTeX has environments and commands to disable justification, but I can't find anything to fully justify a paragraph, including the last line.

Two possibilities:
Ending a line with \linebreak will force the line to be justified, no matter how empty it is.
To do what you are trying to do you could replace \newpage \noindent with \linebreak \newpage \noindent.
Note this will create a blank line before the end of the page, which may or may not be a problem. In certain cases it could create an empty page between your pages.
Another option would be \pagebreak. It tells LaTeX to start a new page when you get to the end of the current line. You don't have control of the exact word where the page break occurs.

What about making the last page (column) shorter using
\enlargethispage{-50mm}
and maybe forcing LaTeX to split after the appropriate line? Of course the amount of shortening should be guessed by trial and error, and re-guessed after changing the text. (Just an idea, may be impossible to implement in your case.)

(Posting for the googlers landing here)
The quickest solution is
\usepackage{pbalance}
(Package documentation at https://ctan.org/pkg/pbalance?lang=de)
In case that does not work, one can try the special command \IEEEtriggeratref{10}, which adds a column break before reference 10. Replace 10 by the actual number of the reference. See the documentation of IEEEtran, section "XIV. Last Page Column Equalization" for more details).

You can adjust the following lengths to make LaTeX fill the last line of a paragraph. Put this in your preamble:
\newcommand{\filllastline}[1]{
\setlength\leftskip{0pt}
\setlength\rightskip{0pt}
\setlength\parfillskip{0pt}
#1}
Then in your document do this:
\filllastline{The text for your partial para in 1st col goes here...}
(For future LaTeX questions you should probable post to https://tex.stackexchange.com/)

Related

Suppress chapter numbers & \renewcommand{\chaptername}

I am writing a amsbook document in Latex. The \chapter{On Banach Spaces} command produces something like this:
CHAPTER 1
On Banach Spaces
I would like it to say
CHAPTER
On Banach Spaces
instead. (No trailing chapter number.)
Why do I want this? I like the layout of amsbook and for the very first chapter I want the leading text to say "INTRODUCTION" then in a next line the title of the introduction. After this introduction I want normal chapter numbering.
This somehow works when I use
\renewcommand{\chaptername}{Introduction}
before the introduction chapter, then
\setcounter{chapter}{0}
\renewcommand\chaptername{Chapter}
just before the second chapter.
Unfortunately this gives me a "INTRODUCTION 1", however I want "INTRODUCTION". So basically, I like to suppress the chapter number.
(Edited.)
I'm not sure I understand your problem 100%, but here are two things to try.
First, I don't know from amsbook, but the regular old book class defines three very-high-level sectioning commands, \frontmatter, \mainmatter, and \backmatter. If you put \frontmatter immediately after \begin{document}, and \mainmatter immediately before the \chapter command for the first chapter that should have a number, then that might well do what you want. However, it may have other effects that you don't want, like changing page breaks or taking things out of the table of contents. (I can't find any online reference for these commands, say sorry.)
A more low-level approach is to use secnumdepth to suppress section numbers. Try something like this:
\setcounter{secnumdepth}{-1}
\chapter{Introduction}
...
\setcounter{secnumdepth}{1} % or 2 for numbered sections, or whatever
\setcounter{chapter}{0}
\chapter{The first chapter}
...
Just type
\chapter*{Introduction}
Then, from the next chapter,
\chapter{The Title of The First Chapter}

Using a single count for figures and tables in LaTeX

I've been given a LaTeX document to edit with the following code for using a single count for figures and tables.
\makeatletter
\newcounter{unisequence}
\def\ucaption{
\ifx\#captype\#undefined
\#latex#error{\noexpand\ucaption outside float}\#ehd
\expandafter\#gobble
\else
\refstepcounter{unisequence}
\expandafter\#firstofone
\fi
{\#dblarg{\#caption\#captype}}
}
\def\thetable{\#arabic\c#unisequence}
\def\thefigure{\#arabic\c#unisequence}
\makeatother
This works well to give a single counter for captions of tables and figures but, I find that if I click on any of the caption numbers in the .pdf this code generates, I am always returned to the first figure or table in the document rather than the one I want, e.g. clicking on in Table [3] will take me to Table 1 instead.
Does anyone know how to fix this? Or can anyone advise an alternative?
I am a LaTeX newbie.
Thanks
Mr Morgan.
Based on https://stackoverflow.com/a/3866061/53974 and https://tex.stackexchange.com/a/127744/1340, we can just (1) make the table counter be the same as the figure counter, and (2) make the table float type be the same as the figure float type, to ensure that the ordering is consistent with the numbering, because:
LaTeX keeps all floats of the same type in order
Code:
\makeatletter
\let\c#table\c#figure % for (1)
\let\ftype#table\ftype#figure % for (2)
\makeatother
Compared to https://stackoverflow.com/a/3866061/53974, this keeps \thetable and \thefigure aloneā€”so the table and figure numbers are kept formatted as-is. This respects per-chapter/section numbering, and it works for me well together with hyperlinking, the subcaption, float and rotating packages, and probably more, on a 160-page document.
If it's of use to anyone, use:
\makeatletter
\renewcommand*{\thetable}{\arabic{table}}
\renewcommand*{\thefigure}{\arabic{figure}}
\let\c#table\c#figure
\makeatother
In the preamble of your document.
Off the top of my head, this is a problem of the snippet you have there not generating the correct reference. See here, for instance: http://en.wikibooks.org/wiki/LaTeX/Hyperlinks
Combining the code in the query with a previous answer worked wonderfully for me - thank you.
To get the figures and tables numbered consecutively within chapters with chapter numbers too, I replaced two lines in the answer snippet by
\renewcommand*{\thetable}{\arabic{chapter}.\arabic{table}}
\renewcommand*{\thefigure}{\arabic{chapter}.\arabic{figure}}

Have one page "normal" while using twocolumn documentclass option

I'm using this configuration in my Latex document:
\documentclass[a4paper,landscape, twocolumn, 10pt]{article}
I'm using twocolumn because I want to have two columns on every page. But now I want to have one page (only one) with only one column (as if I didn't use the twocolumn option) and have the remainder of the document with two columns.
You can issue \onecolumn which will force a page break and start typesetting with the usual one column. When you are finished, issue \twocolumn, which will issue anothe page break and resume typesetting with two columns.
If you don't want page breaks, look at Frank Mittelbach's multicol package.
There's more Latex expertise at tex.stackexchange.com than here, these days.

LaTeX: Prevent line break in a span of text

How can I prevent LaTeX from inserting linebreaks in my \texttt{...} or \url{...} text regions? There's no spaces inside I can replace with ~, it's just breaking on symbols.
Update: I don't want to cause line overflows, I'd just rather LaTeX insert linebreaks before these regions rather than inside them.
\mbox is the simplest answer. Regarding the update:
TeX prefers overlong lines to adding too much space between words on a line; I think the idea is that you will notice the lines that extend into the margin (and the black boxes it inserts after such lines), and will have a chance to revise the contents, whereas if there was too much space, you might not notice it.
Use \sloppy or \begin{sloppypar}...\end{sloppypar} to adjust this behavior, at least a little. Another possibility is \raggedright (or \begin{raggedright}...\end{raggedright}).
Surround it with an \mbox{}
Also, if you have two subsequent words in regular text and you want to avoid a line break between them, you can use the ~ character.
For example:
As we can see in Fig.~\ref{BlaBla}, there is nothing interesting to see. A~better place..
This can ensure that you don't have a line starting with a figure number (without the Fig. part) or with an uppercase A.
Use \nolinebreak
\nolinebreak[number]
The \nolinebreak command prevents LaTeX from
breaking the current line at the point of the command. With the
optional argument, number, you can convert the \nolinebreak command
from a demand to a request. The number must be a number from 0 to 4.
The higher the number, the more insistent the request is.
Source: http://www.personal.ceu.hu/tex/breaking.htm#nolinebreak
Define myurl command:
\def\myurl{\hfil\penalty 100 \hfilneg \hbox}
I don't want to cause line overflows,
I'd just rather LaTeX insert linebreaks before
\myurl{\tt http://stackoverflow.com/questions/1012799/}
regions rather than inside them.

Three columns frame in a big document and renaming stuff in latex

I'm just learning latex, so this may be trivial to some of you.
I went through a few tutorials but they all seem to cover the same things.
I'm writing a big report - calculation all the way (and it has to be neat, because it's part of the documentation). It consists of a frame around the page (15mm margins), and 3 columns inside it: in the left column (3cm wide) are references from where the equation came from (e.g. "ABS 3-2-7"), in the middle is the calculation and in the right is the accepted value (5cm wide). It is a standard way of doing things, so I don't have a choice over the layout.
Now, I don't understand, how would I go in creating such layout ? The frame with columns has to appear on every page. How to accomplish that ?
I've never seen such a document so I'm not sure how to ease the creation.
And second, how do I rename things that are in english language in document classes ? For example, "article" class, I have "References" and I need to have "Literatura".
Is there a way to rename it without touching .cls file?
For your first problem, look at the longtable package (available at ctan.org if you haven't already got it installed)
The problem with using tabular is it won't work as you want across pages.
As far as the second problem, it will depend on the environment and the document type, but typically you'll have to renew a command.
For example, add to the preamble \renewcommand\refname{Literatura} for the article class to do what you were asking for. If I recall correctly it is bibname for books.
Table design in LaTeX has not been made very easy. I would use tabbing rather than tabular and draw the lines manually to keep things simple. A downside is that you don't get any automatic sizing of the table cells, but since your format is fixed, I would consider it a good thing (i.e., if text overflows, you notice it and get to fix it yourself, and your table doesn't accidentally get stretched into the margins). If you use multiple tables like this in your document, try packaging the commands with \newenvironment.
\documentclass{article}
\usepackage[margin=15mm]{geometry}
\usepackage{amsmath}
\usepackage{calc}
\newlength{\tableheight}
\setlength{\tableheight}{20cm} % how high to draw the lines of the table
\newlength{\rulethickness}
\setlength{\rulethickness}{1pt} % how thick lines to draw
\newcommand{\verticalline}{\smash{\rule[-\tableheight]{\rulethickness}{\tableheight}}}
\newlength{\myindent}
\setlength{\myindent}{3mm} % how much to indent each column
\newlength{\leftcolumn}
\setlength{\leftcolumn}{3cm-\myindent}
\newlength{\midcolumn}
\setlength{\midcolumn}{\textwidth-3cm-5cm-\myindent-\rulethickness}
\newlength{\rightcolumn}
\setlength{\rightcolumn}{5cm-\myindent}
\begin{document}
\begin{tabbing}
% first set the tab stops
\hspace*{\myindent}\=\hspace{\leftcolumn}\=%
\hspace{\myindent}\=\hspace{\midcolumn}\=%
\hspace{\myindent}\=\hspace{\rightcolumn}\=\kill
% then draw the lines
\rule{\textwidth}{\rulethickness}\\[-\baselineskip]
\smash{\rule[-\tableheight]{\textwidth}{\rulethickness}}\\[-\baselineskip]
\verticalline\>\>\verticalline\>\>\verticalline\>\>\verticalline\\
% Now start the table: indent the first column with \>
\>ABS 3--2--7
% ... and each additional column with \>\>
\>\> $\iint_{-\infty,-\infty}^{\infty,\infty} e^{-x^2-y^2}\, dx\,dy$
\>\> 2.507
% End each line with \\, add e.g. [2pt] to get 2pt extra space if required
\\[2pt]
% here's another line:
\>ABS 3--2--8 \>\> $\displaystyle\sum_{k=0}^n k^2$ \>\> $\frac12 n(n+1)$ \\
% etc. Be careful not to overflow the table - there's no automatic check for that.
\end{tabbing}
\newpage % also remember to start a new page after the table
\end{document}
To change the fixed names, see this FAQ, or possibly this one if you are using babel.
In this case you probably want to use the tabular environment to generate the three columns (or as simon notes longtable if your report-thingy runs longer than one page). Something like:
\framebox{
\centering
\begin{tabular}{p{3cm}|p{\specialwidth}|p{5cm}}
Ref 1-0-0 & 1.2345 & 1.2346 \\
Ref 1-0-1 & 2.3456 & 2.3454 \\
...
\end{tabular}
}
You'll note that I've used paragraph formatted columns (the p{<length>} formatting specifiers), and stuck a frame around it with \framebox.
You can either compute \specialwidth by hand, or calculate it:
\newlength{\specialwidth}
\setlength{\specialwidth}{\textwidth}
\addtolength{\specialwidth}{-10cm} % extra room for the seperators...
I can't help you on the internationalization issue...

Resources