两列文档中的浮动错误位置

两列文档中的浮动错误位置

首先,我要道歉,因为我几乎把整个文档都抄录在这里了。但是没有它,我就无法展示我想要展示的内容。如果你编译文档,会发现有一个表格会转到最后一页,并停留在中间。我知道如果我更改边距、字体大小等,我可以避免这种情况发生,但我想保留这些设置。

这样,我可以防止表格移到最后一页的中间吗?我的意思是,我可以把它放在页面顶部吗?

此外,我还可以使表格适合\columnwidth,但是由于我在其上使用逐字记录,因此效果不太好。

% arara: pdflatex
% arara: pdflatex
% arara: clean: { files: [ rules.aux, rules.log, rules.out ] }

%\documentclass[a4paper,twocolumn,10pt]{article}
%\documentclass[a4paper,twocolumn,10pt,DIV=15]{scrartcl}
%\documentclass[a4paper,twocolumn,10pt]{scrartcl}
\documentclass[paper=a4,twocolumn,10pt,DIV=calc]{scrartcl}

\setlength{\columnsep}{7.5mm}
%\usepackage[hmargin=15mm,columnsep=7.5mm]{geometry}
\usepackage{microtype}
\usepackage{type1ec}
\usepackage{enumitem}
%\setlist{noitemsep}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{listings}
\lstset{%
    language=[LaTeX]TeX,
    basicstyle=\ttfamily,
    breaklines=true,
    columns=fullflexible,
}
\usepackage{caption}
\usepackage{floatrow}
\floatsetup[table]{capposition=top}
\floatplacement{figure}{ht}
\floatplacement{table}{ht}
\usepackage[colorlinks]{hyperref}
\usepackage{bookmark}
\usepackage{cleveref}
%\usepackage[obeyall,per=slash]{siunitx}[03/05/2012]
\usepackage[detect-all,per-mode=symbol]{siunitx}[03/05/2012]
\usepackage{relsize}

\renewcommand*{\verb}{\lstinline}
\newcommand{\unit}[2]{\mbox{\ensuremath{#1\,\mathrm{#2}}}}
\newcommand*{\TikZ}{\mbox{Ti\emph{k}Z}}
\newcommand*{\pkg}[1]{\texttt{#1}}
\newcommand*{\mail}[1]{\textsmaller{\textless\href{mailto:#1}{\texttt{#1}}\textgreater}}


\begin{document}

\title{Practical and Harmonization Rules for GTEL Book}
\author{Carlos F.~M.~e Silva\\ \mail{[email protected]}}
\date{\today}
\maketitle


\section{Introduction}

Since we are in the last kilometers for the book, which are also the most important ones, it seemed to me reasonable to write some set of \emph{rules} to follow for the book (and for the upcoming books). This will be probably unfinished document, since some rules only come when new situations arrive.

\noindent \textbf{Disclaimer}: These \emph{rules} are not strict. Many aspects are left out of the scope of this document. The author knows that others may have better ways to achieve the same (or even better) result. These also follow the \emph{Contributor's Guide v.2.0}.


\section{Use of em-dash, en-dash, an minus}

In \textsc{Wikipedia} a definition may be found for all kind of uses. The one may want to check out its uses in \url{http://en.wikipedia.org/wiki/Dash}. To be brief, see~\cref{tab:dash_use} for usage examples.

\begin{table*}
\centering
\begin{tabular}{lccl}
\toprule
Sign name & Input      & Looks like & Example of use \\
\midrule
em-dash   & \verb|---| & ---        & The BS---known in LTE as eNB---has its coverage\dots \\
en-dash   & \verb|--|  & --         & The range 1--10 is better to\dots \\
minus     & \verb|-|   & -          & Inter-interference, or in math $1-2=-1$ \\
\bottomrule
\end{tabular}
\caption{Different dash usages}
\label{tab:dash_use}
\end{table*}


\section{Reference chapters, sections, figures, tables, and algorithms}

In preamble, it may be defined some commands as the following, and then use them all over the document.

\begin{lstlisting}
% in preamble
\newcommand*{\ie}{i.e.}
\newcommand*{\eg}{e.g.}
\newcommand*{\ChapRef}[1]{Chapter~\ref{#1}}
\newcommand*{\SecRef}[1]{Section~\ref{#1}}
\newcommand*{\FigRef}[1]{Fig.~\ref{#1}}
\newcommand*{\TabRef}[1]{Table~\ref{#1}}
\newcommand*{\EqRef}[1]{Eq.~\ref{#1}}
\end{lstlisting}


\section{Font for drawings}

The indication from the book's editor is to use Arial font at 10pt. However, if the author wants to use sophisticated tools like: PGF\slash \TikZ, or generate plots via Gnuplot, or even use Inkscape (separating drawing from text) and include then later in the document, there is no easy way to use it in \LaTeX. My suggestion is to use Helvetica and scale it down.

\begin{lstlisting}
% in preamble
\documentclass[10pt]{svmult}
\usepackage[scaled=.8]{helvet}
\end{lstlisting}


\section{Algorithms}

Algorithms are included as figures. It more visual attractive to include a frame around the algorithm and put numbers in the lines.

\begin{lstlisting}
% in preamble
\usepackage{varwidth}
\usepackage{algorithmic}
\usepackage{etoolbox}
%\AtBeginEnvironment{algorithmic}{\normalsize}
\newsavebox{\mybox}
\newenvironment{algbox}
{%
  \begin{lrbox}{\mybox}%
  \begin{varwidth}[b]{\textwidth}%
}{%
  \end{varwidth}%
  \end{lrbox}%
  \fbox{\usebox{\mybox}}%
}

% in document
\begin{figure}
\begin{algbox}
\begin{algorithm}[1]
...
\end{algorithm}
\end{algbox}
\caption{...}
\label{...}
\end{figure}

\end{lstlisting}

The font in algorithms is scaled down to \verb|\small|, however if required to use the text font, the \pkg{etoolbox} provides an easy way to do it: \verb|\AtBeginEnvironment{algorithmic}{\normalsize}|, where now font will be at \verb|\normalsize| for all algorithms.


\section{Use of acronyms}

In technical documents, we often use lots of acronyms. There are some packages in \LaTeX that deal with them. The one that is often used is \pkg{acronym}.

\begin{lstlisting}
% in preamble
\usepackage[printonlyused]{acronym}
\renewcommand{\bflabel}[1]{#1\hfill}
\end{lstlisting}

Lists of acronyms are defined as usual.

\begin{lstlisting}
\begin{acronym}[3GPP ] % write the widest acronym inside '[]'
  \acro{3GPP}{Third Generation Partnership Project}
  \acro{BS}{Base Station}
  \acro{D2D}{Device-to-Device}
\end{acronym}
\end{lstlisting}

Everyone is familiar with \verb|\ac|, \verb|\acs|, \verb|\acl|, and \verb|\acf| commands (there many are others, namely for plurals). However, some rules shall be considered.
%
\begin{itemize}
    \item At chapter, section headings, and captions (figures, tables, and algorithms) use \verb|\acs| for short version and \verb|\acl| for long version, but not \verb|\ac|;
    \item Keep the acronym list manually \textsc{sorted} (\pkg{acronym} cannot do it for us).
\end{itemize}


\section{Use of units}

The use of mathematical units in our documents is very frequent. The \emph{correct} way to display units is to guarantee that there is a thin space between the number and the unit, like \verb|\,|. The one may use \verb|\mbox{30\,m/s}|, or define a command for that \verb|\newcommand{\unit}[2]{\mbox{\ensuremath{#1\,\mathrm{#2}}}}|. However, the better way is to use the \pkg{siunitx} for that, see~\cref{tab:disp_units}.

\begin{lstlisting}
% in preamble
\usepackage[detect-all,per-mode=symbol]{siunitx}[03/05/2012] % TeXLive 2012, Ubuntu 12.04
\end{lstlisting}

\begin{table*}[b]
\centering
\begin{tabular}{llc}
\toprule
& Input & Looks like \\
\cmidrule{2-3}
Plain \LaTeX  & \verb|\mbox{30\,m/s}|              & \mbox{30\,m/s} \\
With command  & \verb|\unit{30}{m/s}|              & \unit{30}{m/s} \\ 
\pkg{siunitx} & \verb|\SI{30}{\meter\per\second}|  & \SI{30}{\meter\per\second} \\
\bottomrule
\end{tabular}
\caption{Display units}
\label{tab:disp_units}
\end{table*}


\section{Table widths}


\section{Miscellaneous}


\subsection{Labels for chapters, sections, figures, tables, and algorithms}

One of the real advantages of \LaTeX over other text processors is its capabilities to handle references. As suggestion, a label shall be defined for each 
chapter, section, figure, table, and algorithm. Also, label shall be defined only after the main command is given: \verb|\chapter|, \verb|\section|, or \verb|caption|.

\begin{lstlisting}
\label{chp:chpname} % chapters
\label{sec:secname} % sections 
\label{fig:figname} % figures
\label{tab:tabname} % tables
\label{alg:algname} % algorithms
...
\end{lstlisting}

An example of usage for a table could be as follows.

\begin{lstlisting}
\begin{table}
...
\caption{...}
\label{tab:table1}
\end{table}
\end{lstlisting}

\end{document}

答案1

首先考虑页面上的两列浮动它们出现在源中(因为第一列已经设置并且无法缩短以腾出空间。

因此您需要允许[t](它仅允许b)并将其在源中向前移动。

在此处输入图片描述

% arara: pdflatex
% arara: pdflatex
% arara: clean: { files: [ rules.aux, rules.log, rules.out ] }

%\documentclass[a4paper,twocolumn,10pt]{article}
%\documentclass[a4paper,twocolumn,10pt,DIV=15]{scrartcl}
%\documentclass[a4paper,twocolumn,10pt]{scrartcl}
\documentclass[paper=a4,twocolumn,10pt,DIV=calc]{scrartcl}

\setlength{\columnsep}{7.5mm}
%\usepackage[hmargin=15mm,columnsep=7.5mm]{geometry}
\usepackage{microtype}
\usepackage{type1ec}
\usepackage{enumitem}
%\setlist{noitemsep}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{listings}
\lstset{%
    language=[LaTeX]TeX,
    basicstyle=\ttfamily,
    breaklines=true,
    columns=fullflexible,
}
\usepackage{caption}
\usepackage{floatrow}
\floatsetup[table]{capposition=top}
\floatplacement{figure}{hpt}
\floatplacement{table}{hpt}
\usepackage[colorlinks]{hyperref}
\usepackage{bookmark}
\usepackage{cleveref}
%\usepackage[obeyall,per=slash]{siunitx}[03/05/2012]
\usepackage[detect-all,per-mode=symbol]{siunitx}[03/05/2012]
\usepackage{relsize}

\renewcommand*{\verb}{\lstinline}
\newcommand{\unit}[2]{\mbox{\ensuremath{#1\,\mathrm{#2}}}}
\newcommand*{\TikZ}{\mbox{Ti\emph{k}Z}}
\newcommand*{\pkg}[1]{\texttt{#1}}
\newcommand*{\mail}[1]{\textsmaller{\textless\href{mailto:#1}{\texttt{#1}}\textgreater}}


\begin{document}

\title{Practical and Harmonization Rules for GTEL Book}
\author{Carlos F.~M.~e Silva\\ \mail{[email protected]}}
\date{\today}
\maketitle


\section{Introduction}

Since we are in the last kilometers for the book, which are also the most important ones, it seemed to me reasonable to write some set of \emph{rules} to follow for the book (and for the upcoming books). This will be probably unfinished document, since some rules only come when new situations arrive.

\noindent \textbf{Disclaimer}: These \emph{rules} are not strict. Many aspects are left out of the scope of this document. The author knows that others may have better ways to achieve the same (or even better) result. These also follow the \emph{Contributor's Guide v.2.0}.


\section{Use of em-dash, en-dash, an minus}

In \textsc{Wikipedia} a definition may be found for all kind of uses. The one may want to check out its uses in \url{http://en.wikipedia.org/wiki/Dash}. To be brief, see~\cref{tab:dash_use} for usage examples.

\begin{table*}
\centering
\begin{tabular}{lccl}
\toprule
Sign name & Input      & Looks like & Example of use \\
\midrule
em-dash   & \verb|---| & ---        & The BS---known in LTE as eNB---has its coverage\dots \\
en-dash   & \verb|--|  & --         & The range 1--10 is better to\dots \\
minus     & \verb|-|   & -          & Inter-interference, or in math $1-2=-1$ \\
\bottomrule
\end{tabular}
\caption{Different dash usages}
\label{tab:dash_use}
\end{table*}


\section{Reference chapters, sections, figures, tables, and algorithms}

In preamble, it may be defined some commands as the following, and then use them all over the document.

\begin{lstlisting}
% in preamble
\newcommand*{\ie}{i.e.}
\newcommand*{\eg}{e.g.}
\newcommand*{\ChapRef}[1]{Chapter~\ref{#1}}
\newcommand*{\SecRef}[1]{Section~\ref{#1}}
\newcommand*{\FigRef}[1]{Fig.~\ref{#1}}
\newcommand*{\TabRef}[1]{Table~\ref{#1}}
\newcommand*{\EqRef}[1]{Eq.~\ref{#1}}
\end{lstlisting}


\section{Font for drawings}

The indication from the book's editor is to use Arial font at 10pt. However, if the author wants to use sophisticated tools like: PGF\slash \TikZ, or generate plots via Gnuplot, or even use Inkscape (separating drawing from text) and include then later in the document, there is no easy way to use it in \LaTeX. My suggestion is to use Helvetica and scale it down.

\begin{lstlisting}
% in preamble
\documentclass[10pt]{svmult}
\usepackage[scaled=.8]{helvet}
\end{lstlisting}


\section{Algorithms}

Algorithms are included as figures. It more visual attractive to include a frame around the algorithm and put numbers in the lines.

\begin{lstlisting}
% in preamble
\usepackage{varwidth}
\usepackage{algorithmic}
\usepackage{etoolbox}
%\AtBeginEnvironment{algorithmic}{\normalsize}
\newsavebox{\mybox}
\newenvironment{algbox}
{%
  \begin{lrbox}{\mybox}%
  \begin{varwidth}[b]{\textwidth}%
}{%
  \end{varwidth}%
  \end{lrbox}%
  \fbox{\usebox{\mybox}}%
}

% in document
\begin{figure}
\begin{algbox}
\begin{algorithm}[1]
...
\end{algorithm}
\end{algbox}
\caption{...}
\label{...}
\end{figure}

\end{lstlisting}

The font in algorithms is scaled down to \verb|\small|, however if required to use the text font, the \pkg{etoolbox} provides an easy way to do it: \verb|\AtBeginEnvironment{algorithmic}{\normalsize}|, where now font will be at \verb|\normalsize| for all algorithms.


\section{Use of acronyms}

\begin{table*}[btp]
\centering
\begin{tabular}{llc}
\toprule
& Input & Looks like \\
\cmidrule{2-3}
Plain \LaTeX  & \verb|\mbox{30\,m/s}|              & \mbox{30\,m/s} \\
With command  & \verb|\unit{30}{m/s}|              & \unit{30}{m/s} \\ 
\pkg{siunitx} & \verb|\SI{30}{\meter\per\second}|  & \SI{30}{\meter\per\second} \\
\bottomrule
\end{tabular}
\caption{Display units}
\label{tab:disp_units}
\end{table*}


In technical documents, we often use lots of acronyms. There are some packages in \LaTeX that deal with them. The one that is often used is \pkg{acronym}.

\begin{lstlisting}
% in preamble
\usepackage[printonlyused]{acronym}
\renewcommand{\bflabel}[1]{#1\hfill}
\end{lstlisting}

Lists of acronyms are defined as usual.

\begin{lstlisting}
\begin{acronym}[3GPP ] % write the widest acronym inside '[]'
  \acro{3GPP}{Third Generation Partnership Project}
  \acro{BS}{Base Station}
  \acro{D2D}{Device-to-Device}
\end{acronym}
\end{lstlisting}

Everyone is familiar with \verb|\ac|, \verb|\acs|, \verb|\acl|, and \verb|\acf| commands (there many are others, namely for plurals). However, some rules shall be considered.
%
\begin{itemize}
    \item At chapter, section headings, and captions (figures, tables, and algorithms) use \verb|\acs| for short version and \verb|\acl| for long version, but not \verb|\ac|;
    \item Keep the acronym list manually \textsc{sorted} (\pkg{acronym} cannot do it for us).
\end{itemize}


\section{Use of units}

The use of mathematical units in our documents is very frequent. The \emph{correct} way to display units is to guarantee that there is a thin space between the number and the unit, like \verb|\,|. The one may use \verb|\mbox{30\,m/s}|, or define a command for that \verb|\newcommand{\unit}[2]{\mbox{\ensuremath{#1\,\mathrm{#2}}}}|. However, the better way is to use the \pkg{siunitx} for that, see~\cref{tab:disp_units}.

\begin{lstlisting}
% in preamble
\usepackage[detect-all,per-mode=symbol]{siunitx}[03/05/2012] % TeXLive 2012, Ubuntu 12.04
\end{lstlisting}



\section{Table widths}


\section{Miscellaneous}


\subsection{Labels for chapters, sections, figures, tables, and algorithms}

One of the real advantages of \LaTeX over other text processors is its capabilities to handle references. As suggestion, a label shall be defined for each 
chapter, section, figure, table, and algorithm. Also, label shall be defined only after the main command is given: \verb|\chapter|, \verb|\section|, or \verb|caption|.

\begin{lstlisting}
\label{chp:chpname} % chapters
\label{sec:secname} % sections 
\label{fig:figname} % figures
\label{tab:tabname} % tables
\label{alg:algname} % algorithms
...
\end{lstlisting}

An example of usage for a table could be as follows.

\begin{lstlisting}
\begin{table}
...
\caption{...}
\label{tab:table1}
\end{table}
\end{lstlisting}

\end{document}

相关内容