從兩列縱向到一列橫向:強製文字和頁碼(在橫向模式下)位於左邊距

從兩列縱向到一列橫向:強製文字和頁碼(在橫向模式下)位於左邊距

請幫助我在下一個程式碼中將文字Hola和頁碼強製2到旋轉頁面的左上角。

注意:我正在使用兩列縱向文檔,需要臨時更改為一列橫向文檔,文字Hola位於左上角邊框。

謝謝!

\documentclass[twocolumn]{article}

% Packages for various functionalities
\usepackage{lipsum} % For dummy text; you can remove this in your actual document
\usepackage{graphicx} % For including images
\usepackage{caption} % For captions
\usepackage{authblk} % For author affiliations
\usepackage{longtable} % For long tables
\usepackage{pdflscape} % For landscape pages
\usepackage[margin=1in]{geometry} % Adjust margins as desired
\usepackage{showframe} % To display page borders
\usepackage{geometry} %to change page margins
 \geometry{
 letterpaper,
 left=10mm,
 top=10mm,
 bottom=10mm,
 right=10mm
 }
 
% Title and authors
\title{Your Title Here}
\author[1]{Author One}
\author[2]{Author Two}
\affil[1]{Affiliation One}
\affil[2]{Affiliation Two}

\begin{document}

\maketitle

\section{Introduction}
% ... (Sections and content here)


\begin{landscape}
\newgeometry{margin=2cm, top=2cm, bottom=2cm, left=2cm, right=2cm} % Adjust margins for landscape page
\clearpage %needed for next command
\onecolumn %reset to one column mode


Hola

\clearpage %needed for next command
\twocolumn %reset to two-column mode
\restoregeometry %return to initial page margins
\end{landscape}


\section{Discussion}
% ... (Remaining content here)

\end{document}

目前的糟糕結果如下圖所示:

在此輸入影像描述

我想要如下圖的結果(左邊):

在此輸入影像描述

答案1


2024 年 1 月 4 日星期四 22:24 (UTC +0000) 編輯:

問題一:

TeX - LaTeX Stack Exchange Chat Ulrike Fischer 指出\newgeometry包裝的幾何學onecolumn儘管透過 切換到一列模式,但您需要應用- 選項\onecolumn

問題2:

打字區塊是儲存文件頁面文字的方塊。 (不是頁首/頁腳,也不是頁邊註釋。)

但在 LaTeX 中沒有引入參數/長度\typeblockwidth/ 。\typeblockheight

相反,每個\textwidth\textheight都確定兩件事:

任何狀況之下

  • \textwidth是確定類型塊的水平延伸。
  • \textheight是確定類型塊的垂直延伸。

如果打字區塊內的文字水平對齊

  • \textwidth也可以確定適合打字區塊的文字行的最大長度。
  • \textheight也可以確定可用於在打字區塊內將文字行彼此重疊放置的空間量。

如果打字區塊內的文字垂直對齊

  • \textwidth也可以確定可用於在打字區塊內將文字行彼此重疊放置的空間量。
  • \textheight也可以確定適合打字區塊的文字行的最大長度。

landscape在包包的環境內景觀1 \textheight被更改以確定頁面的類型區塊內將文字行彼此疊置的可用空間量,同時頁面的類型區塊內的這些行垂直對齊。

此更改忽略了這樣一個事實:\textheight在任何情況下(無論類型區塊中的文字是水平對齊還是垂直對齊)都是為了確定類型區塊的垂直擴展。

landscape即,雖然包的環境景觀1生效,\textheight不再確定類型塊的垂直延伸。

\ShowFramePicture但隨著包包的套路展示架為了繪製框架,(正確地,恕我直言)假設\textheight在任何情況下都確定了類型區塊的垂直擴展。

因此景觀1 修改\textheight需要在繪製一組框架之前撤銷\ShowFramePicture

因此,我決定\ShowFramePicturelandscape-environment 中重新定義以\textheight(僅)在繪製框架時有效的本地範圍內重置。

1包裝pdf風景內部負載景觀landscape並修改包的環境景觀這樣,當環境landscape有效時,請向發送至 .pdf 檔案的每個頁面新增 pdf 檢視器指令,以在螢幕上顯示該頁面旋轉 90 度的角度。此指令僅影響頁面在電腦螢幕/用於檢視 .pdf 檔案的顯示器上的顯示方式。指令其實並不影響TeX 的排版工作。它會影響用於查看 pdf 文件的程式的「顯示工作」。儘管在環境landscape有效的情況下排版並發貨的頁面,排版塊的文本行是垂直對齊的,但您不需要向左或向右傾斜頭部來在屏幕/顯示器上閱讀它們,因為這些頁面顯示旋轉90 度,以便您可以透過從左到右查看電腦的螢幕/顯示器來閱讀它們。


\documentclass[twocolumn, letterpaper]{article}

% Packages for various functionalities
\usepackage{lipsum} % For dummy text; you can remove this in your actual document
\usepackage{graphicx} % For including images
\usepackage{caption} % For captions
\usepackage{authblk} % For author affiliations
\usepackage{longtable} % For long tables
\usepackage{pdflscape} % For landscape pages
\usepackage{geometry} %to change page margins
\usepackage{showframe} % To display page borders

\geometry{
 letterpaper,
 left=20mm,
 top=20mm,
 bottom=20mm,
 right=20mm
}

\newcommand\savetextheight{}%

% Title and authors
\title{Your Title Here}
\author[1]{Author One}
\author[2]{Author Two}
\affil[1]{Affiliation One}
\affil[2]{Affiliation Two}

\begin{document}

\maketitle

\section{Introduction}
%... (Sections and content here)
\lipsum[1-8]

\onecolumn %reset to one column mode
\newgeometry{onecolumn, margin=2cm, top=2cm, bottom=2cm, left=2cm, right=2cm}% Adjust margins for landscape page

\edef\savetextheight{\number\textheight\space sp\relax}%
\begin{landscape}%
\makeatletter
\renewcommand\ShowFramePicture{%
  \begingroup
    % -------------------------------------------------------------------------------------------
    %  \textheight is modified within the landscape-environment because the box holding the text
    %  is rotated. But the frames around the text are drawn on the sheet of paper, which during
    %  typesetting is not rotated (, although pdflscape tells pdf-viewers to display it rotated).
    %  Thus modification of \textheight is to be undone while drawing the frames:
    % -------------------------------------------------------------------------------------------
    \textheight=\savetextheight
    % -------------------------------------------------------------------------------------------
    \ShowFrameColor\linethickness{\ShowFrameLinethickness}%
    \AtPageLowerLeft{%
      \framebox(\paperwidth,\paperheight){}}%
    \AtTextLowerLeft{%
      \framebox(\textwidth,\textheight){}}%
    \AtTextUpperLeft{%
      \put(0,\headsep){%
        \framebox(\textwidth,\headheight){}}}%
    \AtTextLowerLeft{%
      \put(0,-\footskip){%
        \line(1,0){\textwidth}}}%
    \AtTextLowerLeft{%
      \SF@tempdima=\textwidth\advance\SF@tempdima\marginparsep
      \if@twoside
        \ifodd\c@page\else
          \if@mparswitch
            \SF@tempdima=-\marginparsep\advance\SF@tempdima-\marginparwidth
          \fi
        \fi
      \fi
      \put(\SF@tempdima,0)%
        {\framebox(\marginparwidth,\textheight){}}%
    }%
  \endgroup
}
\makeatother
\noindent Hola \lipsum[1-18]
\clearpage
\lipsum[1-8]
\end{landscape}%

\twocolumn
\restoregeometry %return to initial page margins

\section{Discussion}
% ... (Remaining content here)
\lipsum[1-8]

\end{document}
在此輸入影像描述

答案2

歡迎來到 TeX.SE!

以下 MWE(最小工作範例)重現了您的第二張相關圖像:

\documentclass[twocolumn]{article}
\usepackage[letterpaper,
            margin=1in]{geometry} % Adjust margins as desired

\usepackage{afterpage} % For landscape pages
\usepackage{pdflscape} % For landscape pages

% Packages for various functionalities
\usepackage{lipsum} % For dummy text; you can remove this in your actual document
\usepackage{graphicx} % For including images
\usepackage{caption} % For captions
\usepackage{authblk} % For author affiliations
\usepackage{longtable} % For long tables
                    

% Title and authors
\title{Your Title Here}
\author[1]{Author One}
\author[2]{Author Two}
\affil[1]{Affiliation One}
\affil[2]{Affiliation Two}

\begin{document}
\pagestyle{plain}

\maketitle

\section{Introduction}
\lipsum[1-4]

\afterpage{%
    \clearpage
\newgeometry{margin=20mm} % Adjust margins for landscape page
\onecolumn              % reset to one column mode
    \begin{landscape}

Hola, landscape here!

\lipsum[1-3]

    \end{landscape}
\restoregeometry %return to initial page margins
\twocolumn %reset to two-column mode
            }% end afterpage          
\lipsum[6]

\section{Discussion}
\lipsum[7-13]

\end{document}

在此輸入影像描述

目前尚不完全清楚您喜歡在哪裡添加頁碼。到目前為止,我將它們保留為預設位置(以腳為中心)。

如果您希望在其他地方使用頁碼,則需要定義新的頁首/頁尾樣式,例如使用 usefancyhdr包。例如,在序言中添加

\usepackage{fancyhdr}    
\fancypagestyle{LandScape}%
{%
\fancyhf{}%
\fancyhead[L]{\thepage}%
\renewcommand{\headrulewidth}{0pt}%
\renewcommand{\footrulewidth}{0pt}%
}

\begin{landscape}在文檔正文之前插入

\pagestyle{LandScape}

結果頁面樣式為:

在此輸入影像描述

編輯:

  • 目前尚不清楚為什麼要定義\newgeometry它與其他文件(面向縱向)頁面幾何形狀具有相同的設定。在這種情況下,我不會使用它,即在你的情況下,我會簡單地刪除它。
  • 如果在所有頁面上正確繪製頁面佈局框架是您主要關心的問題,那麼您應該堅持使用 @Ulrich Diez 提出的解決方案(+1)。
  • 他的解決方案採用了我原來的答案,並稍微修改了程式碼,如下 MWE 所示:
\documentclass[twocolumn]{article}
\usepackage[letterpaper,
            margin=1in]{geometry} % Adjust margins as desired
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.5pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}     % For dummy text; in actual document
                        % you can/should remove it

\newcommand\savetextheight{}%
\edef\savetextheight{\number\textheight\space sp\relax}%
\makeatletter%
\renewcommand\ShowFramePicture{%
    \textheight=\savetextheight
%---------------------------------------------------------------%
\ShowFrameColor\linethickness{\ShowFrameLinethickness}%
\AtTextLowerLeft{% text box
  \framebox(\textwidth,\textheight){}}%
\AtTextUpperLeft{% page header
  \put(0,\headsep){%
    \framebox(\textwidth,\headheight){}}}%
\AtTextLowerLeft{% page margin
  \put(0,-\footskip){%
    \line(1,0){\textwidth}}}%
\AtTextLowerLeft{%  when document is twoside
  \SF@tempdima=\textwidth\advance\SF@tempdima\marginparsep
  \if@twoside
    \ifodd\c@page\else
      \if@mparswitch
        \SF@tempdima=-\marginparsep\advance\SF@tempdima-\marginparwidth
      \fi
    \fi
  \fi
  \put(\SF@tempdima,0)%
    {\framebox(\marginparwidth,\textheight){}}%
                }% end of twoside
                    }% end of \renewcommand
\makeatother

% Packages for various functionalities
\usepackage{afterpage}  % For remove empty space on page before 
                        % landscape page with text after it
\usepackage{pdflscape}  % For landscape pages
\usepackage{graphicx}   % For including images
\usepackage{caption}    % For captions
\usepackage{authblk}    % For author affiliations
\usepackage{longtable}  % For long tables


% Title and authors
\title{Your Title Here}
\author[1]{Author One}
\author[2]{Author Two}
\affil[1]{Affiliation One}
\affil[2]{Affiliation Two}

%---------------------------------------------------------------%
\begin{document}
\maketitle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Introduction}
\lipsum[1-4]

\afterpage{%
    \clearpage
\onecolumn                  % reset to one column mode
\begin{landscape}%
Hola, landscape here!

\lipsum[1-2]

\begin{longtable}[htb]{|p{\dimexpr\textwidth-2\tabcolsep}|}
\caption{Longtable: width = \texttt{textwidth}} \\
    \hline
\lipsum[66] \\
    \hline
\end{longtable}

\begin{longtable}[htb]{|p{\dimexpr\textheight-2\tabcolsep}|}
\caption{Longtable: width = \texttt{textheight}} \\
    \hline
\lipsum[66] \\
    \hline
\end{longtable}

\begin{longtable}[htb]{|p{\dimexpr\linewidth-2\tabcolsep}|}
\caption{Longtable: width = \texttt{linewidth}} \\
    \hline
\lipsum[66] \\
    \hline
\end{longtable}

\end{landscape}%
\twocolumn
        }% end \afterpage


\section{Discussion}
\lipsum[1-8]

\end{document}

在此輸入影像描述

相關內容