이미지가 텍스트를 아래로 끌어당기는 이유는 무엇입니까?

이미지가 텍스트를 아래로 끌어당기는 이유는 무엇입니까?

그림을 포함할 때마다 텍스트가 아래로 당겨집니다. 나는 그것을 원하지 않습니다. 텍스트가 평범하고 이미지가 현재 페이지나 너무 크면 다음 페이지 중 어디에나 들어갈 수 있기를 바랍니다.

MWE는 다음과 같습니다.

\documentclass{book}

\usepackage[utf8]{inputenc}
\usepackage[margin = 2cm]{geometry}
\usepackage{array}
\setlength{\arrayrulewidth}{1mm}
\setlength{\tabcolsep}{18pt}
\renewcommand{\arraystretch}{1.5}
\usepackage{color}
\newcommand{\compl}[1]{ \textcolor{darkblue}{\textbf{\hl{ #1 }}}}
\definecolor{seccol}{rgb}{0,0.8,0.3}

\usepackage{graphicx}

\begin{document}

    In a fully implemented Operating System, any global variables that need to be initialized before they are used, and any library initialization code needs to be called before these libraries cna be used. In our modest project, there are only a couple of libraries, but they need to be initialized nonetheless. Also, the  section must be cleared (i.e we must write a 0 to all addresses in the section). All of this is done in the  function.
    \\
    Although very humble in it's current state, if the project is extended so that more functionality is added, this is where we would call any library initialization code, in order to ensure that everything is setup before any function in a library gets called. 
    \\~\\
    The very first thing we want to do is clear the  section. Thanks to our, we have a label to indicate exactly where this section begins and another label to indicate exactly where it ends, the script also ensures that all  sections of all files get contiguously put together in the final kernel image, so we know that, once we clear this section, all variables that need to be initialized to 0 will contain their correct values. Since the addresses form a continuous block of memory, we can

        In a fully implemented Operating System, any global variables that need to be initialized before they are used, and any library initialization code needs to be called before these libraries cna be used. In our modest project, there are only a couple of libraries, but they need to be initialized nonetheless. Also, the  section must be cleared (i.e we must write a 0 to all addresses in the section). All of this is done in the function.
        \\
        Although very humble in it's current state, if the project is extended so that more functionality is added, this is where we would call any library initialization code, in order to ensure that everything is setup before any function in a library gets called. 
        \\~\\
        The very first thing we want to do is clear the  section. Thanks to our , we have a label to indicate exactly where this section begins and another label to indicate exactly where it ends, the script also ensures that all sections of all files get contiguously put together in the final kernel image, so we know that, once we clear this section, all variables that need to be initialized to 0 will contain their correct values. Since the addresses form a continuous block of memory, we can

                The very first thing we want to do is clear the  section. Thanks to our , we have a label to indicate exactly where this section begins and another label to indicate exactly where it ends, the script also ensures that all sections of all files get contiguously put together in the final kernel image, so we know that, once we clear this section, all variables that need to be initialized to 0 will contain their correct values. Since the addresses form a continuous block of memory, we can
\centering
\includegraphics{FramebufferDiagram.png}
\end{document}

[1]: https://i.stack.imgur.com/7lNPf.png

답변1

figure사진을 떠다니게 하려면 환경 에 사진을 넣어야 합니다 .

\begin{figure}
\centering
\includegraphics{FramebufferDiagram.png}
\end{figure}

선택적 인수를 추가하여 위치 지정을 설정할 수 있습니다. h여기(소스에 나타나는 위치), t페이지 상단 및/또는 b페이지 하단( \begin{figure}[ht]여기에 넣거나 맞지 않으면 다음 페이지 상단에 넣기 위해) .

참고: 텍스트는 페이지의 절반 정도만 채웁니다. 그리고 클래스를 사용하고 있기 때문에 book더 많은 텍스트를 추가할 때까지 계속 늘어납니다. 이는 book클래스가 모든 페이지를 동일한 높이로 만들려고 하기 때문입니다.

편집하다:

페이지가 늘어나는 것을 방지하기 위해 \raggedbottom서문에 넣습니다. 그러면 LaTeX는 더 이상 모든 페이지를 같은 높이로 만들려고 시도하지 않습니다.

Btw.: 사진이 떠다니는 것을 원하지 않으니 \centering\includegraphics그룹( {...})에 넣는 것이 좋습니다. 이렇게 하면 이미지 뒤의 텍스트가 더 이상 중앙에 배치되지 않습니다. (내 생각에는 당신이 이것을 원하지 않는 것 같습니다.)

답변2

설명이 너무 깁니다. 대신에 다음 \raggedbottom을 사용하는 것을 해결하지 마십시오.\\~\\빈 줄(= \par)문단 사이에 빈 줄을 두는 것은 완전히 잘못된 것입니다. 줄 바꿈을 두 개만 삽입하고 있습니다. 이내에단락. 그럼에도 불구하고 단락 건너뛰기는 다르며 가짜 단락에는 단락 들여쓰기가 없습니다.

게다가 마지막 문단의 끝 부분 앞에 배치하여 \centering이미지뿐만 아니라 마지막 문단도 중앙에 오도록 했습니다. 이미지도 단락의 일부이며 거대한 캐릭터처럼 행동하므로 높이가 좀 더 낮으면 "...memory, we can"과 같은 줄로 끝납니다. 그렇지 않으면 다음 페이지로 넘어가되 약 10cm의 "구멍"을 남겨 두십시오. 그런 다음 LaTeX는 텍스트를 수직으로 정렬하기 위해 늘어나는 실제 단락 사이에 고무 간격을 사용합니다. 이는 이미지가 다른 단락에 있는 경우에도 발생합니다.

단락 사이에 고정된 공간을 원할 경우 다음과 같은 명령을 사용해야 합니다.

\setlength{\parskip}{\baselineskip}

\raggedbottom이제 단락 슬립은 고무 길이가 아닌 고정 길이이므로 이것이 전혀 필요하지 않습니다 .

그럼에도 불구하고 일반적으로 다음과 같이 조정 가능한 길이를 두는 것이 훨씬 좋습니다(그러나 페이지의 모든 단락에서 동일).

\setlength{\parskip}{.5em plus .1em minus .1em}      

parskip또는 더 간단하게: 서문에 있는 패키지를 사용하세요 .

이 경우에는 라텍스가 하나의 악과 다른 악 사이에서 결정하도록 강제하기 때문에 이것은 분명히 좋은 해결책이 아닙니다(페이지의 절반 정도를 비워두거나 원하는 만큼 먼 문단 사이에 넓은 공간을 남겨두기). 이 경우의 해결책은 Gustavo Mezzetti가 잘 지적한 것처럼 플로트 또는 옵션을 사용하는 것입니다. h그러면 t이미지 p가 더 이상 일반 단락의 일부가 아니기 때문입니다.

그림과 위 및/또는 아래 텍스트 사이에 적절한 공간을 남겨두기 때문에 플로트가 일반적으로 바람직하다는 점은 언급할 가치가 있습니다(그리고 번호가 매겨진 캡션, 그림 목록, 수직으로만 중앙에 있는 이미지 등을 허용함).

플로트가 없는 MWE:

음

\documentclass{book}
\usepackage[margin=2cm]{geometry}
\setlength{\parskip}{\baselineskip}
\usepackage{graphicx}
\usepackage{kantlipsum} % allow \kant[n] for dummy paragraphs
\begin{document}
\kant[2]\par\kant[1]\par\kant[2]\par\kant[1]\par

\centering
\includegraphics[height=12cm]{example-image}
\end{document}

부동소수점이 있는 MWE:

음

\documentclass{book}
\usepackage[margin=2cm]{geometry}
\setlength{\parskip}{.5em plus .1em minus .5em}
\usepackage{graphicx}
\usepackage{kantlipsum} % allow \kant[n] for dummy paragraphs
\begin{document}
\kant[2]\par\kant[1]\par\kant[2]\par\kant[1]
\begin{figure}[h]
\centering
\includegraphics[height=12cm]{example-image}
\end{figure}
\end{document}

참고: \par(=빈 줄)은 이미 매크로에 암시되어 있지만 \kant단락이 다음으로 끝나는 점을 표시하기 위해 MWE에 남겨 둡니다 \par(물론 추가 \par는 무시되기 때문입니다).

관련 정보