將行拉伸到 \textwidth 而不開始新行

將行拉伸到 \textwidth 而不開始新行

我有一個圖,包含三個帶標題的子圖和整個圖的標題,所有這些加起來超過了一整頁。

我可以更改特定頁面的幾何形狀,使圖形看起來適合它,但隨後 LaTex 會留下空白,因為幾何形狀的更改似乎會在插入的位置創建分頁符號。我嘗試將幾何變化放在浮動中,這樣 LaTex 可以將其視為浮動,只需更改圖形恰好出現的頁面的大小,但這只會給我帶來一堆錯誤。

我還嘗試將圖形準確地放在文檔中我想要的位置,但那是在一個段落內,該段落被圖形打破了。為了直觀地使其顯示出來,如果段落在圖之後繼續,我嘗試\newline在圖之前和下一頁上延伸頁面的最後一行,\noindent以使其在沒有新段落的情況下出現,但後來我認為\newline開始了新行會導致我的圖形之前出現整個空白頁,這非常不是我想要的。

我也嘗試過使用該\makebox命令。如果我將每個插入到subfigure一個盒子中,這是可行的,但隨後我不知道如何減少上邊距,這是使其適合所需的。我還需要使整個圖形的標題更寬,但是當創建一個比\textwidth事物寬的框時不再居中,並且當我嘗試將整個圖形放入 中時makebox,它不會編譯。

有沒有辦法讓浮動比頁面大以便表現良好,或者拉伸一條線以適應\textwidth而不開始新行,就像\newline看起來那樣?

由於我的問題似乎有些不清楚,我相信我應該提供一個範例程式碼。我對它的長度感到抱歉,但是如果你編譯它,我認為很容易理解我的問題是什麼。如果沒有,請告訴我,我會盡力問得更好。我不知道如何將編譯的文檔新增到問題中,或者我會的。

\documentclass[twocolumn]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{sectsty}
\usepackage[margin=1in]{geometry}
\usepackage{braket}
\usepackage{amsmath}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\usepackage{float}

\usepackage{tikz}
\usepackage{lipsum}



\begin{document}
\section{See last part of this section}
\lipsum[1-8]
\noindent\makebox[\linewidth]{\rule{0.5\textwidth}{1pt}}
\textbf{\large{And then there is some more text which I made large and bold here so you wont miss is. The important thing is that there is a paragraph right before the figure, and I don't what that to leave a pretty much empty page as it has here.}} 

\onecolumn
\begin{figure}
\centering
    \makebox[1\textwidth][c]{
        \begin{subfigure}{1.2\textwidth}
        \begin{tikzpicture}
            \node at(0,0) {\includegraphics[width=0.5\textwidth]{x}};
            \node at(0.5\textwidth,0) {\includegraphics[width=0.5\textwidth]{x}};
        \end{tikzpicture}
        \caption{\textbf{\large{All captions to this figure are really long, and at you can see they don't fit into the page.}} Readout spectra of the transitions from $\ket{\pm 5/2 g}$ to all three excited states and the transition $\ket{\pm 1/2 g} \rightarrow \ket{\pm 5/2 e}$ at 4 MHz in the spectra. (left) The three peaks corresponding to the transitions $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$, $\ket{\pm 5/2 g} \rightarrow \ket{\pm 3/2 e}$ and $\ket{\pm 5/2 g} \rightarrow \ket{\pm 5/2 e}$, positioned at 0, 2 and 6 MHz respectively, are present as expected. However, there is also a peak at $\ket{\pm 1/2 g} \rightarrow \ket{\pm 5/2 e}$ at 4 MHz. This comes from some unwanted ion class, and must therefore be some other transition than $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$. (right) After burning at  $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$ the two first peaks disappear. The last one, corresponding to $\ket{\pm 5/2 g} \rightarrow \ket{\pm 5/2 e}$ is still there, although somewhat smaller. This means that also in this peak there are unwanted ions from some other ions class. The peak at $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$ is still there and has become bigger, as expected.}
    \end{subfigure}}
\makebox[1\textwidth][c]{
    \begin{subfigure}{1.2\textwidth}
        \begin{tikzpicture}
            \node at(0,0) {\includegraphics[width=0.5\textwidth]{x}};
            \node at(0.5\textwidth,0) {\includegraphics[width=0.5\textwidth]{x}};
    \end{tikzpicture}
    \caption{Another really long caption. Readout spectra of the transitions from $\ket{\pm 5/2 g}$ to all three excited states and the transition $\ket{\pm 1/2 g} \rightarrow \ket{\pm 5/2 e}$ at 4 MHz in the spectra. (left) The three peaks corresponding to the transitions $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$, $\ket{\pm 5/2 g} \rightarrow \ket{\pm 3/2 e}$ and $\ket{\pm 5/2 g} \rightarrow \ket{\pm 5/2 e}$, positioned at 0, 2 and 6 MHz respectively, are present as expected. However, there is also a peak at $\ket{\pm 1/2 g} \rightarrow \ket{\pm 5/2 e}$ at 4 MHz. This comes from some unwanted ion class, and must therefore be some other transition than $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$. (right) After burning at  $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$ the two first peaks disappear. The last one, corresponding to $\ket{\pm 5/2 g} \rightarrow \ket{\pm 5/2 e}$ is still there, although somewhat smaller. This means that also in this peak there are unwanted ions from some other ions class. The peak at $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$ is still there and has become bigger, as expected.}
        \end{subfigure}}
    \makebox[1\textwidth][c]{
        \begin{subfigure}{1.2\textwidth}
            \begin{tikzpicture}
                \node at(0,0) {\includegraphics[width=0.5\textwidth]{x}};
                \node at(0.5\textwidth,0) {\includegraphics[width=0.5\textwidth]{x}};
        \end{tikzpicture}
        \caption{A this really long caption. Readout spectra of the transitions from $\ket{\pm 5/2 g}$ to all three excited states and the transition $\ket{\pm 1/2 g} \rightarrow \ket{\pm 5/2 e}$ at 4 MHz in the spectra. (left) The three peaks corresponding to the transitions $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$, $\ket{\pm 5/2 g} \rightarrow \ket{\pm 3/2 e}$ and $\ket{\pm 5/2 g} \rightarrow \ket{\pm 5/2 e}$, positioned at 0, 2 and 6 MHz respectively, are present as expected. However, there is also a peak at $\ket{\pm 1/2 g} \rightarrow \ket{\pm 5/2 e}$ at 4 MHz. This comes from some unwanted ion class, and must therefore be some other transition than $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$. (right) After burning at  $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$ the two first peaks disappear. The last one, corresponding to $\ket{\pm 5/2 g} \rightarrow \ket{\pm 5/2 e}$ is still there, although somewhat smaller. This means that also in this peak there are unwanted ions from some other ions class. The peak at $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$ is still there and has become bigger, as expected.}
    \end{subfigure}}
    \onecolumn
    \caption{And a caption for the whole figure. Readout spectra of the transitions from $\ket{\pm 5/2 g}$ to all three excited states and the transition $\ket{\pm 1/2 g} \rightarrow \ket{\pm 5/2 e}$ at 4 MHz in the spectra. (left) The three peaks corresponding to the transitions $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$, $\ket{\pm 5/2 g} \rightarrow \ket{\pm 3/2 e}$ and $\ket{\pm 5/2 g} \rightarrow \ket{\pm 5/2 e}$, positioned at 0, 2 and 6 MHz respectively, are present as expected. However, there is also a peak at $\ket{\pm 1/2 g} \rightarrow \ket{\pm 5/2 e}$ at 4 MHz. This comes from some unwanted ion class, and must therefore be some other transition than $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$. (right) After burning at  $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$ the two first peaks disappear. The last one, corresponding to $\ket{\pm 5/2 g} \rightarrow \ket{\pm 5/2 e}$ is still there, although somewhat smaller. This means that also in this peak there are unwanted ions from some other ions class. The peak at $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$ is still there and has become bigger, as expected.}
\twocolumn
\end{figure}
\twocolumn

\section{Then I tried the geometry package, please read the last paragraph also here}

\lipsum[1-7]
\vspace{100pt}

\noindent\makebox[\linewidth]{\rule{0.5\textwidth}{1pt}}

\textbf{\large{The geometry package has worked best so far.}} Then I can make the figure fit by changing the top margin. However I still have the 

\newgeometry{textwidth=19.5cm,textheight=29cm,top=1.5cm, bottom=3cm}
\begin{figure*}
\centering
\includegraphics[scale=1]{x}
    \caption{Let's skip the figure as you now know why it is too big.}
\end{figure*}
\restoregeometry

problem that the figure does not fit nicely within the paragraph, but a lot of white space appears. I tried to avoid this by placing the figure exactly where I wanted it within the paragraph. As you can see, the paragraph is broken by the figure, which does not seem to be allowed to float and just change the geometry of the page it happens to appear on. Do you see my problem?

\section{Then I tried to avoid the breaking of the paragraph, at least visually}

\lipsum[1-6]
\vspace{120pt}

\noindent\makebox[\linewidth]{\rule{0.5\textwidth}{1pt}}
So I tried to visually make it seem as there was not break in the paragraph by using the          \textbackslash newline and \textbackslash noindent commands, but as you can see, this gave me an entire blank page before the figure which I \newline 

\newgeometry{textwidth=19.5cm,textheight=29cm,top=1.5cm, bottom=3cm}
\begin{figure*}
\centering
\includegraphics[scale=1]{x}
    \caption{I've been using the starred figure because I want the figure to span the entire page, as I have a twocolumn environment otherwise.}
\end{figure*}
\restoregeometry

\noindent don't know how to get rid of! 

I hope my question(s) are more clear now. And I am sorry for all the messy code, but I do think it is essential for understanding my problem. I hope you can help me. :)

\end{document}

答案1

粗體段落後的空白頁只是因為您用 強制分頁\onecolumn。我不確定您想要的佈局,但您想避免強制中斷並使用表單*允許頁面寬度浮動,例如

\documentclass[twocolumn]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{sectsty}
\usepackage[margin=1in]{geometry}
\usepackage{braket}
\usepackage{amsmath}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\usepackage{float}

\usepackage{tikz}
\usepackage{lipsum}

\newenvironment{outdent}
               {\list{}{\leftmargin-1cm
\rightmargin\leftmargin}%
                \item\relax}
               {\endlist}


\begin{document}
\section{See last part of this section}
\lipsum[1-8]
\noindent\makebox[\linewidth]{\rule{0.5\textwidth}{1pt}}
\textbf{\large{And then there is some more text which I made large and bold here so you wont miss is. The important thing is that there is a paragraph right before the figure, and I don't what that to leave a pretty much empty page as it has here.}} 


\begin{figure*}
\vspace*{-50pt}
\begin{outdent}
\centering
    \makebox[1\textwidth][c]{
        \begin{subfigure}{1.2\textwidth}
        \begin{tikzpicture}
            \node at(0,0) {\includegraphics[width=0.5\textwidth]{x}};
            \node at(0.5\textwidth,0) {\includegraphics[width=0.5\textwidth]{x}};
        \end{tikzpicture}
        \caption{\textbf{\large{All captions to this figure are really long, and at you can see they don't fit into the page.}} Readout spectra of the transitions from $\ket{\pm 5/2 g}$ to all three excited states and the transition $\ket{\pm 1/2 g} \rightarrow \ket{\pm 5/2 e}$ at 4 MHz in the spectra. (left) The three peaks corresponding to the transitions $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$, $\ket{\pm 5/2 g} \rightarrow \ket{\pm 3/2 e}$ and $\ket{\pm 5/2 g} \rightarrow \ket{\pm 5/2 e}$, positioned at 0, 2 and 6 MHz respectively, are present as expected. However, there is also a peak at $\ket{\pm 1/2 g} \rightarrow \ket{\pm 5/2 e}$ at 4 MHz. This comes from some unwanted ion class, and must therefore be some other transition than $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$. (right) After burning at  $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$ the two first peaks disappear. The last one, corresponding to $\ket{\pm 5/2 g} \rightarrow \ket{\pm 5/2 e}$ is still there, although somewhat smaller. This means that also in this peak there are unwanted ions from some other ions class. The peak at $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$ is still there and has become bigger, as expected.}
    \end{subfigure}}
\makebox[1\textwidth][c]{
    \begin{subfigure}{1.2\textwidth}
        \begin{tikzpicture}
            \node at(0,0) {\includegraphics[width=0.5\textwidth]{x}};
            \node at(0.5\textwidth,0) {\includegraphics[width=0.5\textwidth]{x}};
    \end{tikzpicture}
    \caption{Another really long caption. Readout spectra of the transitions from $\ket{\pm 5/2 g}$ to all three excited states and the transition $\ket{\pm 1/2 g} \rightarrow \ket{\pm 5/2 e}$ at 4 MHz in the spectra. (left) The three peaks corresponding to the transitions $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$, $\ket{\pm 5/2 g} \rightarrow \ket{\pm 3/2 e}$ and $\ket{\pm 5/2 g} \rightarrow \ket{\pm 5/2 e}$, positioned at 0, 2 and 6 MHz respectively, are present as expected. However, there is also a peak at $\ket{\pm 1/2 g} \rightarrow \ket{\pm 5/2 e}$ at 4 MHz. This comes from some unwanted ion class, and must therefore be some other transition than $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$. (right) After burning at  $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$ the two first peaks disappear. The last one, corresponding to $\ket{\pm 5/2 g} \rightarrow \ket{\pm 5/2 e}$ is still there, although somewhat smaller. This means that also in this peak there are unwanted ions from some other ions class. The peak at $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$ is still there and has become bigger, as expected.}
        \end{subfigure}}
    \makebox[1\textwidth][c]{
        \begin{subfigure}{1.2\textwidth}
            \begin{tikzpicture}
                \node at(0,0) {\includegraphics[width=0.5\textwidth]{x}};
                \node at(0.5\textwidth,0) {\includegraphics[width=0.5\textwidth]{x}};
        \end{tikzpicture}
        \caption{A this really long caption. Readout spectra of the transitions from $\ket{\pm 5/2 g}$ to all three excited states and the transition $\ket{\pm 1/2 g} \rightarrow \ket{\pm 5/2 e}$ at 4 MHz in the spectra. (left) The three peaks corresponding to the transitions $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$, $\ket{\pm 5/2 g} \rightarrow \ket{\pm 3/2 e}$ and $\ket{\pm 5/2 g} \rightarrow \ket{\pm 5/2 e}$, positioned at 0, 2 and 6 MHz respectively, are present as expected. However, there is also a peak at $\ket{\pm 1/2 g} \rightarrow \ket{\pm 5/2 e}$ at 4 MHz. This comes from some unwanted ion class, and must therefore be some other transition than $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$. (right) After burning at  $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$ the two first peaks disappear. The last one, corresponding to $\ket{\pm 5/2 g} \rightarrow \ket{\pm 5/2 e}$ is still there, although somewhat smaller. This means that also in this peak there are unwanted ions from some other ions class. The peak at $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$ is still there and has become bigger, as expected.}
    \end{subfigure}}

    \caption{And a caption for the whole figure. Readout spectra of the transitions from $\ket{\pm 5/2 g}$ to all three excited states and the transition $\ket{\pm 1/2 g} \rightarrow \ket{\pm 5/2 e}$ at 4 MHz in the spectra. (left) The three peaks corresponding to the transitions $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$, $\ket{\pm 5/2 g} \rightarrow \ket{\pm 3/2 e}$ and $\ket{\pm 5/2 g} \rightarrow \ket{\pm 5/2 e}$, positioned at 0, 2 and 6 MHz respectively, are present as expected. However, there is also a peak at $\ket{\pm 1/2 g} \rightarrow \ket{\pm 5/2 e}$ at 4 MHz. This comes from some unwanted ion class, and must therefore be some other transition than $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$. (right) After burning at  $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$ the two first peaks disappear. The last one, corresponding to $\ket{\pm 5/2 g} \rightarrow \ket{\pm 5/2 e}$ is still there, although somewhat smaller. This means that also in this peak there are unwanted ions from some other ions class. The peak at $\ket{\pm 5/2 g} \rightarrow \ket{\pm 1/2 e}$ is still there and has become bigger, as expected.}

\vspace*{-5pt}
\end{outdent}
\end{figure*}


\section{Then I tried the geometry package, please read the last paragraph also here}

\lipsum[1-7]
\vspace{100pt}

\noindent\makebox[\linewidth]{\rule{0.5\textwidth}{1pt}}

\textbf{\large{The geometry package has worked best so far.}} Then I can make the figure fit by changing the top margin. However I still have the 

\begin{figure*}
\begin{outdent}
\centering
\includegraphics[scale=1]{x}
    \caption{Let's skip the figure as you now know why it is too big.}
\end{outdent}
\end{figure*}


problem that the figure does not fit nicely within the paragraph, but a lot of white space appears. I tried to avoid this by placing the figure exactly where I wanted it within the paragraph. As you can see, the paragraph is broken by the figure, which does not seem to be allowed to float and just change the geometry of the page it happens to appear on. Do you see my problem?

\section{Then I tried to avoid the breaking of the paragraph, at least visually}

\lipsum[1-6]
\vspace{120pt}

\noindent\makebox[\linewidth]{\rule{0.5\textwidth}{1pt}}
So I tried to visually make it seem as there was not break in the paragraph by using the          \textbackslash newline and \textbackslash noindent commands, but as you can see, this gave me an entire blank page before the figure which I \newline 


\begin{figure*}
\centering
\includegraphics[scale=1]{x}
    \caption{I've been using the starred figure because I want the figure to span the entire page, as I have a twocolumn environment otherwise.}
\end{figure*}


\noindent don't know how to get rid of! 

I hope my question(s) are more clear now. And I am sorry for all the messy code, but I do think it is essential for understanding my problem. I hope you can help me. :)

\end{document}

答案2

在 MWE 中, 的文字\lipsum[4]出現在第 1 頁上,從而避免了 OP 引用的頁面底部的空白區域。

我使用 a\makebox[\textwidth]{}將超寬圖片延伸到水平邊距之外。我使用 a\smash來折疊圖像的垂直範圍。然而,這會使標題垂直位於頁面中間,因此我必須\rule在圖像中添加 a minipage,將標題向下推,規則的範圍小於\textheight並控制標題的最終位置。

\documentclass[11pt]{report}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\begin{document} 
\lipsum[1-3]
\begin{figure}[p]
\begin{minipage}{\textwidth}
  \rule{0pt}{7.5in}%
  \smash{\makebox[\textwidth]{\includegraphics[width=7in,height=8.5in]{x}}}
\end{minipage}
\caption{this is my figure caption}
\end{figure}
\lipsum[4-9]
\end{document}

在此輸入影像描述

在此輸入影像描述

相關內容