Растянуть строку до \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для сворачивания вертикального размера изображения. Однако, просто это оставило бы подпись посреди страницы по вертикали, поэтому мне пришлось добавить a \ruleк изображению 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}

введите описание изображения здесь

введите описание изображения здесь

Связанный контент