[LaTeX] box algorithm adjustbox subfigures, textwidth
Posted aban-mtd
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[LaTeX] box algorithm adjustbox subfigures, textwidth相关的知识,希望对你有一定的参考价值。
algorithm
\begin{figure}[!t]
\vspace*{\dimexpr\fboxsep+\fboxrule}
\fbox{%
\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{\raggedright
\begin{algorithmic}[1]
\STATE $L(p) = -1$, $p = 1,\ldots,N$.
\STATE $D(p) = +\infty$, $p = 1,\ldots,N$.
\FOR{$t=1$ to $T$}
\FOR{$k=1$ to $K$}
\FOR{$p \in S^t(k)$}
\IF{$D(p,k) < D(p)$}
\STATE $D(p) = D(p,k)$
\STATE $L(p) = k$
\ENDIF
\ENDFOR
\ENDFOR
\STATE Update new cluster center.
\STATE Update new search space.
\ENDFOR
\end{algorithmic}%
}}
\caption{caption.}
\label{fig:lkm_algo}
\end{figure}
adjustbox
% [email protected]:~/$ pdflatex
%\usepackage{graphicx} % graphicx must before adjustbox!!
%\usepackage{adjustbox}
\begin{figure}[!ht]
\centering
\adjustbox{width=\columnwidth,trim={.05\width} 0 {.09\width} {.05\height},clip}%
{%
\includegraphics[width=\columnwidth]{test.png}%
}
\caption{Caption here.}
\label{fig:lb}
\end{figure}
subfigures cross column
% \usepackage{graphicx}
\begin{figure*}[!ht]
\centering
\subfloat[]
{\includegraphics[width=0.32\linewidth]{1.png}%
\label{fig:m_r1}}
\hfil
\subfloat[]
{\includegraphics[width=0.32\linewidth]{2.png}%
\label{fig:m_r2}}
\hfil
\subfloat[]
{\includegraphics[width=0.32\linewidth]{3.png}%
\label{fig:m_r3}}\\
\subfloat[]
{\includegraphics[width=0.32\linewidth]{4.png}%
\label{fig:m_f1}}
\hfil
\subfloat[]
{\includegraphics[width=0.32\linewidth]{5.png}%
\label{fig:m_f2}}
\hfil
\subfloat[]
{\includegraphics[width=0.32\linewidth]{6.png}%
\label{fig:m_f3}}
%
\caption{caption here!}
\label{fig:m}
\end{figure*}
subfigure with adjustbox
\documentclass{IEEEtran}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{lipsum}
\ifCLASSOPTIONcompsoc
\usepackage[caption=false,font=normalsize,labelfont=sf,textfont=sf]{subfig}
\else
\usepackage[caption=false,font=footnotesize]{subfig}
\fi
%%
\begin{figure}[!htb]
\centering
\vfill
\subfloat[]%
{\adjustbox{width=\columnwidth,trim={.04\width} 0 {.09\width} {.05\height},clip}%
{%
\includegraphics[width=\columnwidth]{1.jpg}%
}}\\
\subfloat[]%
{\adjustbox{width=\columnwidth,trim={.04\width} 0 {.09\width} {.05\height},clip}%
{%
\includegraphics[width=\columnwidth]{1.jpg}%
}}
\caption{caption}
\label{fig:kalkuebr}
\end{figure}
text width
\hsize
is the main parameter that TeX uses when typesetting: whenever it finishes a paragraph it looks at the current value of \hsize
for breaking it into horizontal boxes. Next, there are \leftskip
and \rightskip
and possibly other paragraph shape parameters (\hangindent
and \hangafter
or the more general \parshape
).
LaTeX uses an indirect approach and maintains many \...width
parameters.
\textwidth
is generally the global width of the text area, while \columnwidth
is the width of a column of text (it will be different from \textwidth
when typesetting in two or more columns). However, inside a minipage, \textwidth
will be set to the given argument along with \hsize
, \columnwidth
, and \linewidth
(they will revert to the previous values at the end of the minipage because it forms a group). Note that \parbox
doesn’t reset \textwidth
; the size is available as \linewidth
.
The parameter \linewidth
contains the line length inside a list (or derived) environment and it may change in a nested list (while \hsize
, \textwidth
and \columnwidth
don’t change).
When we have to specify a length depending on current conditions, we have to use the correct parameter. For example, the width of a figure should be specified in terms of \columnwidth
in a figure environment and of \textwidth
in a figure* environment; however this is done rarely when it’s known that the document will be typeset in one column format. The same should be for a tabular* or tabularx environment.
Instead, when we need something centered with respect to a line in a list, we should use \linewidth
:
\begin{enumerate}
\item some text that contains a `here‘ table
\begin{center}
\begin{tabularx}{.9\linewidth}{lXX}
...
\end{tabularx}
\end{center}
and some other text that follows.
\item ...
\end{enumerate}
In this case it would be wrong to use \textwidth
or \columnwidth
, as the line length is “unknown” at typing time.
Notice that LaTeX uses \hangindent
only for typesetting sectional titles and \leftskip
and rightskip
for \centering
, \raggedright
and \raggedleft
; the indentation of a list environment is obtained via \parshape
.
以上是关于[LaTeX] box algorithm adjustbox subfigures, textwidth的主要内容,如果未能解决你的问题,请参考以下文章