paracol and footnote placing in Latex - latex

For my current project I need two text lined up in two column. The idea is that one column shows the original language and the second column its translation, neatly lined up line by line. The package paracol does what I want except for one thing: footnote placement.
If one of the columns has a footnote and the other hasn't, the lines of the original and the translation do not stay together. The footnote disrupts the lining up of lines.
This is an example in which you can see that "some other text that should be next to the line in the left column" is not lined up with the lines of the original. All because of the footnote.
\documentclass[twoside,a4paper,11pt]{book}
\usepackage{paracol}
\usepackage{lipsum}
\begin{document}
\begin{paracol}{2}
\lipsum[1-2]
\switchcolumn
\lipsum[1-2]
\switchcolumn
text with footnote\footnote{the footnote}
and some other text
\switchcolumn
the translation without footnote
some other text that should be next to the line in the left column
\end{paracol}
\end{document}
As you can see, the footnote disrupts the alignment of lines. How to remedy this?

I found the solution to my own problem by adding the following line after loading the paracol package:
\footnotelayout{p}
This ensures that footnotes are layed out for the whole page instead of the default of per column.
(Since I also added footmisc with the perpage parameter, I also had to delete the perpage parameter and add this:
\usepackage{everypage}
\AddEverypageHook{\setcounter{footnote}{0}} % resets footnote counter on every page
)

Related

How to start new line after paragraph title in Lyx?

I am using the Lyx document processor for LaTeX.
I need to use the Paragraph environment (because I have Subsubsubsections), and I want the paragraphs to appear in the Table of Contents.
I managed to get the Paragraph to appear in the TOC by changing the Document Settings. However, the text right after the title does NOT start in a new line.
I sort of fixed this by inserting ERT (LaTeX code) \newline.
However, now I have a problem because the page number for the paragraphs in the table of contents is also being shown on the next line! (Instead of to the right of the page, under the other page numbers.)
So how do I get the paragraph's body text to start from a new line, without affecting the TOC?
Thank you.
To get new lines after paragraphs, you need to re-define the paragraph command.
Go to
Document -> Settings -> Latex Preamble
and add
\renewcommand\paragraph{\#startsection{paragraph}{4}{\z#}%
{-3.25ex\#plus -1ex \#minus -.2ex}%
{1.5ex \#plus .2ex}%
{\normalfont\normalsize\bfseries}}
Src: http://www.latex-community.org/forum/viewtopic.php?f=5&t=1383
Modify the second and third lines to increase or decrease the space before and after the paragraph title.
For additional information about \#startsection (in case you need more tweaks)
http://infohost.nmt.edu/tcc/help/pubs/nmtthesis/old/annotated/at.startsection.html

margin note with tabbing environment in latex

I need to put a margin note next to a tabbing environment. If I try to use \marginpar within the environment I get an error: LaTeX Error: Not in outer par mode.
I've tried putting the \marginpar just before the \begin of the environment but it ends up aligned with the last line of the preceding paragraph instead of with the first line of the tabbing environment.
In the example below the first margin note gets aligned above the tabbing text and the second one below. I tried using \vspace to shift the top note down, and that works okay unless a page break occurs between the tabbing environment and the preceding paragraph -- then the margin note and the tabbing text end up on separate pages.
Any ideas how to get the margin note to line up with the top of the tabbing text?
\documentclass{memoir}
\begin{document}
Now is the time for all good men to come to the aid of their country.
\marginpar{a margin note}\begin{tabbing}
tabbing text a\\
tabbing text b\\
\end{tabbing}\marginpar{another margin note}
Now is the time for all good men to come to the aid of their country.
\end{document}
The marginnote package provides a work-around for this:
\documentclass{memoir}
\usepackage{marginnote}% http://ctan.org/pkg/marginnote
\begin{document}
Now is the time for all good men to come to the aid of their country.
\begin{tabbing}
tabbing text a \marginnote{a margin note} \\
tabbing text b
\end{tabbing}
Now is the time for all good men to come to the aid of their country.
\end{document}

positions of page numbers, position of chapter headings, chapters AND Table of Contents, References

I am writing my PhD thesis (120+ pages) in latex, the deadline is approaching and I am struggling with layout problems.
I am using the documentstyle book.
I am posting both problems in this one thread because I am not sure if the solution might be related to both problems or not.
Problems are:
1.) The page numbers are mostly located on the top-right of each page (this is correct and where I want them to be).
However, only on the first page of chapters and on the first page of what I call "special chapters", the page number is located bottom-centered.
With "special chapters" I mean: List of Contents, List of Figures, List of Tables, References, Index.
My university will not accept the thesis like this. The page number must ALWAYS be top-right one each page, even if the page is the first page of a chapter or the first page of something like the List of Contents.
How can I fix this?
2.) On the first page of chapters and "special chapters" (List of Contents...), the chapter title is located far too low on the page. This is the standard layout of LaTeX with documentstyle book I think.
However, the chapter title must start at the very top of the page! I.e. the same height as the normal text on the pages that follow.
I mean the chapter title, not the header.
I.e., if there is a chapter called
"Chapter 1
Dynamics of foobar under mechanical stress"
then that text has to start from the top the page, but right now it starts several centimeters below the top.
How can I fix this?
Have tried all kinds of things to no effect, I'd be very thankful for a solution!
Thanks.
A try to answer
problem #1.
Even if you're using the headings pagestyle, or your custom pagestyle, the special pages (chapter beginnings and so on) are formatted with the plain pagestyle.
To avoid this, load the fancyhdr package (as mentioned in the previous answer) with
\usepackage{fancyhdr}
in your preamble. Then, (always in the preamble) define your custom pagestyle.
For normal pages (assuming you're not using twoside as an option of \documentclass[]{}):
\fancypagestyle{phdthesis}{%
\fancyhf %clear all headers and footers fields
\fancyhead[R]{\thepage} %prints the page number on the right side of the header
}
For special pages:
\fancypagestyle{plain}{%redefining plain pagestyle
\fancyhf %clear all headers and footers fields
\fancyhead[R]{\thepage} %prints the page number on the right side of the header
}
After doing this, you can set you page style declaring \pagestyle{phdthesis} right before \begin{document}.
For further details, refer to the fancyhdr package documentation.
Now trying to answer
problem #2
As a first attempt, you can use the titlesec package, using the option compact. In the preamble, type:
\usepackage[compact]{titlesec}
If you're not completely satisfied with this solution, you can specify the spacing above and below the titles with \titlespacing
\usepackage{titlesec}
\titleformat{ command }[ shape ]{ format }{ label }{ sep }{ before }[ after ]
\titlespacing{ command }{ left }{ beforesep }{ aftersep }[ right ]
With \titleformat you can define your own style for chapter titles, and then you can define the spacing with \titlespacing.
I don't know which style of titles you have to use, so it's better for you to have a look to the package documentation (you can recall package documentation typing texdoc NameOfThePackage in a terminal).
Please note that you need to define the chapter title format in order to specify its vertical spacing (page 5 of the documentation). As an example:
\usepackage{titlesec}
\titleformat{\chapter}[hang]{\huge}{\thechapter}{1em}{}
\titlespacing{\chapter}{0pt}{0pt}{1cm}
With these commands you have the chapter title with the number and the chapter name on the same line, a 0 pt space before the title, and a 1 cm space between the title and the follwing text.
To change the page appearance, you can use the fancyhdr package. It's probably a change in the \pagestyle used for the special chapters.
To change the appearance of the chapter title (to have the chapter title printed from the top on the page, you have to use a modified style that change \chapter command rendering.
Here is an example of command I used for my own thesis. It is probably not the appearance you want but gives you an hint about the command you have to redefine.
% modified from book.ltx latex sources
\def\#makechapterhead#1{%
\thispagestyle{empty}%
\vspace*{50\p#}%
\vspace*{10\p#}%
{\parindent \z# \centering \reset#font
\thickhrulefill\quad
\scshape \#chapapp{} \thechapter
\quad \thickhrulefill
\par\nobreak
\vspace*{10\p#}%
\interlinepenalty\#M
\hrule
\vspace*{10\p#}%
\Huge \bfseries #1\par\nobreak
\par
\vspace*{10\p#}%
\hrule
\vskip 40\p#}}
Regarding problem #2 an alternative without additional packages is to change the vertical offset of the page, and then resetting it to the previous value.
\voffset -1in
\chapter{Your chapter}
% text
\voffset 0in

Is there unresizable space in latex? Pictures in good looking grid

I've created latex macro to typeset guitar chords diagrams(using picture environment).
Now I want to make diagrams of different appear in good looking grid when typeset one next to each other as the picture shows:
The picture.
(on the picture: Labeled "First" bad layout of diagrams, labeled "Second" correct layout when equal number of diagrams in line)
I'm using \hspace to make some skips between diagrams, otherwise they would be too near to each other. As you can see in second case when latex arrange pictures in so that there is same number of them in each line it works. However if there is less pictures in the last line they become "shifted" to the right. I don't want this.
I guess is because latex makes the space between diagrams in first line a little longer for the line to exactly fit the page width. How do I tell latex not to resize spaces created by \hspace ? Or is there any other way ?
I guess I cannot use tables because I don't know how many diagrams will fit in one line...
This is current state of code:
\newcommand{\spaceForChord}{1.7cm}
\newcommnad{\chordChart}[1]{%
%calculate dimensions xdim and ydim according to settings
\begin{picture}(xdim, ydim){%
%draw the diagram inside defined area
}%
\hspace*{\spaceForChord}%
\hspace*{-\xdim}%
}%
%end preambule and begin document
\begin{document}
First:\\*
\\*
\chordChart{...some arguments to change diagram look...}
\chordChart{...some arguments to change diagram look...}
\chordChart{...some arguments to change diagram look...}
\chordChart{...some arguments to change diagram look...}
\chordChart{...some arguments to change diagram look...}
%...above line is repeated 12 more times to produce result shown at the picture
\end{document}
Thanks for any help.
A long shot, since I can't easily recreate your situation: would wrapping a flushleft environment around your \chordCart be of any help?
I.e.,
First:\\*
\begin{flushleft}
\chordChart{...some arguments to change diagram look...}
...
\end{flushleft}
Second:\\*
If your hypothesis is correct and LaTeX is indeed trying to stretch spaces to justify lines, then the above should solve your problem by turning off justification on the right.

LaTeX table positioning

I have a LaTeX document that contains a paragraph followed by 4 tables followed by a second paragraph. I want the 4 tables to appear between the two paragraphs which from what I've read means I should use the [h] option after beginning the table environment (e.g. \begin{table}[h]).
Using this the first two tables appear after paragraph 1 as expected, however paragraph 2 is then displayed with the last two tables appearing on the following page. How can I get the tables to appear in the correct location?
I've tried various things to correct the positioning such as using [h!] however this doesn't seem to have any effect. Using \clearpage after the tables does have the desired effect of making the tables appear before the second paragraph but it then leaves the last two tables on their own page with loads of white-space, when I would prefer to have the second paragraph begin immediately after the tables.
Paragraph 1...
\begin{table}[h]
table1...
\end{table}
\begin{table}[h]
table2...
\end{table}[h]
...
Paragraph 2...
After doing some more googling I came across the float package which lets you prevent LaTeX from repositioning the tables.
In the preamble:
\usepackage{float}
Then for each table you can use the H placement option (e.g. \begin{table}[H]) to make sure it doesn't get repositioned.
Table Positioning
Available Parameters
A table can easily be placed with the following parameters:
h Place the float here, i.e., approximately at the same point it occurs in the source text (however, not exactly at the spot)
t Position at the top of the page.
b Position at the bottom of the page.
p Put on a special page for floats only.
! Override internal parameters LaTeX uses for determining "good" float positions.
H Places the float at precisely the location in the LATEX code. Requires the float package. This is somewhat equivalent to h!.
If you want to make use of H (or h!) for an exact positioning, make sure you got the float package correctly set up in the preamble:
\usepackage{float}
\restylefloat{table}
Example
If you want to place the table at the same page, either at the exact place or at least at the top of the page (what fits best for the latex engine), use the parameters h and t like this:
\begin{table}[ht]
table content ...
\end{table}
Sources: Overleaf.com
At the beginning with the usepackage definitions include:
\usepackage{placeins}
And before and after add:
\FloatBarrier
\begin{table}[h]
\begin{tabular}{llll}
....
\end{tabular}
\end{table}
\FloatBarrier
This places the table exactly where you want in the text.
Here's an easy solution, from Wikibooks:
The placeins package provides the command \FloatBarrier, which can be used to prevent floats from being moved over it.
I just put \FloatBarrier before and after every table.
What happens if the text plus tables plus text doesn't fit onto a single page? By trying to force the typesetting in this way, you are very likely to end up with pages that run too short; i.e., because a table cannot by default break over a page it will be pushed to the next, and leave a gap on the page before. You'll notice that you never see this in a published book.
The floating behaviour is a Good Thing! I recommend using [htbp] as the default setting for all tables and figures until your document is complete; only then should think about fine-tuning their precise placement.
P.S. Read the FAQ; most other answers here are partial combinations of advice given there.
If you want to have two tables next to each other you can use: (with float package loaded)
\begin{table}[H]
\begin{minipage}{.5\textwidth}
%first table
\end{minipage}
\begin{minipage}{.5\textwidth}
%second table
\end{minipage}
\end{table}
Each one will have own caption and number.
Another option is subfigure package.
In my case I was having an issue where the table was not being displayed right after the paragraph I inserted it, so I simply changed
\begin{table}[]
to
\begin{table}[ht]
You may want to add this to your preamble, and adjust the values as necessary:
%------------begin Float Adjustment
%two column float page must be 90% full
\renewcommand\dblfloatpagefraction{.90}
%two column top float can cover up to 80% of page
\renewcommand\dbltopfraction{.80}
%float page must be 90% full
\renewcommand\floatpagefraction{.90}
%top float can cover up to 80% of page
\renewcommand\topfraction{.80}
%bottom float can cover up to 80% of page
\renewcommand\bottomfraction{.80}
%at least 10% of a normal page must contain text
\renewcommand\textfraction{.1}
%separation between floats and text
\setlength\dbltextfloatsep{9pt plus 5pt minus 3pt }
%separation between two column floats and text
\setlength\textfloatsep{4pt plus 2pt minus 1.5pt}
Particularly, the \floatpagefraction may be of interest.
Not necessary to use \restylefloat and destroys other options, like caption placement. just use [H] or [!h] after \begin{table}.

Resources