从两列纵向到单列横向:强制将文本和页码(横向模式)置于左边距

从两列纵向到单列横向:强制将文本和页码(横向模式)置于左边距

请帮助我在下一个代码中将文本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):

问题 1:

TeX - LaTeX Stack Exchange 聊天 Ulrike Fischer 指出\newgeometry包装中的几何学onecolumn尽管可以通过 切换到单列模式,但您仍需要应用-option \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

因此,我决定\ShowFramePicture在环境中重新定义,以在绘制框架时有效的本地范围内landscape重置(仅)。\textheight

1软件包pdflscape内部加载景观landscape并修改包的环境景观因此,在环境生效时,向 .pdf 文件发送的每一页都landscape添加了一个指令,让 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}

在此处输入图片描述

不太清楚您想将页码放在何处。到目前为止,我保留了默认位置(页脚居中)。

如果您希望将页码放在其他位置,则需要定义新的页眉/页脚样式,例如使用fancyhdr包。例如,在序言中添加

\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}

在此处输入图片描述

相关内容