Last active
April 15, 2024 05:30
-
-
Save Liam0205/014661fe1fb0c337bfa0dd3242430015 to your computer and use it in GitHub Desktop.
widetext.sty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[twocolumn]{article} | |
\usepackage{mwe} | |
\usepackage{widetext} | |
\begin{document} | |
\blindtext | |
\begin{widetext} | |
\[ | |
E = mc^2. | |
\] | |
\end{widetext} | |
\blindtext | |
\begin{widetext} | |
\begin{table} | |
\begin{center} | |
\caption{fake} | |
\begin{tabular}{cc} | |
\hline | |
fake & table \\ | |
\hline | |
\end{tabular} | |
\end{center} | |
\end{table} | |
\end{widetext} | |
\blindtext | |
\end{document} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\NeedsTeXFormat{LaTeX2e} | |
\ProvidesPackage{widetext} | |
%% Mimics the widetext environment of revtex4 for any other class package | |
%% Eg: article.cls | |
%% | |
%% Authored by: Liam Huang | |
%% | |
%% Advantages: | |
%% *) Supports float (eg: figure) in two column format (Advantage over | |
%% multicol package) | |
%% *) One and twocolumn exist on the same page | |
%% *) Flow of text shown via rule | |
%% *) Equal height of text when in two column format | |
%% | |
%% Acknowledgment(s): | |
%% 1. Instead of re-inventing the wheel, two packages (flushend, cuted) of | |
%% the sttools bundle are used. The sttools bundle is available from CTAN. | |
%% Lisence of these packages rests with their corresponding author. | |
%% Any bug/problem with flushend and cuted should be forwarded to their | |
%% corresponding package authors. | |
%% 2. The idea of the rule came from the following latex community website | |
%% http://www.latex-community.org/forum/viewtopic.php?f=5&t=2770 | |
%% | |
%% This package just defines the widetext environment and the rules. | |
%% | |
%% Usage: | |
%% \documentclass[a4paper,12pt,twocolumn]{article} | |
%% \usepackage{widetext} | |
%% | |
%% \begin{document} | |
%% | |
%% Some text in twocolumn | |
%% | |
%% \begin{widetext} | |
%% Text in onecolumn format. | |
%% \end{widetext} | |
%% | |
%% Some more text in twocolumn | |
%% | |
%% \end{document} | |
%%%%%%%%%%%%%%%%%%%% | |
\newlength\wttlinewidth | |
\setlength{\wttlinewidth}{0.4pt} | |
\@ifpackageloaded{etoolbox}{\relax}{ | |
\IfFileExists{etoolbox.sty} | |
{\RequirePackage{etoolbox}} | |
{\typeout{} | |
\typeout{Package widetext error: Install the etoolbox package. Available from CTAN.} | |
\typeout{} | |
\stop | |
} | |
} | |
\AtBeginEnvironment{widetext}{% | |
\renewenvironment{figure}[1][htb]% | |
{% | |
\let\oldcaption\caption | |
\renewcommand\caption{\def\@captype{figure}\oldcaption}% | |
}{} | |
\renewenvironment{table}[1][htb]% | |
{% | |
\let\oldcaption\caption | |
\renewcommand\caption{\def\@captype{table}\oldcaption}% | |
}{} | |
} | |
\AtBeginDocument{% | |
% Firstly, test which method of two-column document is being used | |
\@ifpackageloaded{multicol} % test \[email protected] | |
{ | |
\newlength\@parindent | |
\setlength\@parindent{\parindent} | |
\newenvironment{widetext}[1][2]{% | |
\gdef\savedcolnum{#1} | |
\noindent | |
\rule{\dimexpr(0.5\textwidth-0.5\columnsep-0.4pt)}{\wttlinewidth}% | |
\par %\vspace{6pt} | |
\parindent \@parindent | |
}{% | |
\par | |
\hfill | |
\rule[0.5\baselineskip] | |
{\dimexpr(0.5\textwidth-0.5\columnsep-1pt)}{\wttlinewidth}% | |
} | |
\BeforeBeginEnvironment{widetext}{\end{multicols}} | |
\AfterEndEnvironment{widetext}{\begin{multicols}{\savedcolnum}} | |
}{% if the multicol package is not used, test if LaTeX standard twocolumn is used | |
\if@twocolumn | |
\@ifpackageloaded{flushend}{\relax}{ | |
\IfFileExists{flushend.sty} | |
{\RequirePackage{flushend}} | |
{\typeout{} | |
\typeout{Package widetext error: Install the flushend package. Available from CTAN.} | |
\typeout{} | |
\stop | |
} | |
} | |
\@ifpackageloaded{cuted}{\relax}{ | |
\IfFileExists{cuted.sty} | |
{\RequirePackage{cuted}} | |
{\typeout{} | |
\typeout{Package widetext error: Install the cuted package. Available from CTAN.} | |
\typeout{} | |
\stop | |
} | |
} | |
\newlength\@parindent | |
\setlength\@parindent{\parindent} | |
\newenvironment{widetext}[1][2] | |
{% | |
\begin{strip} | |
\rule{\dimexpr(0.5\textwidth-0.5\columnsep-0.4pt)}{\wttlinewidth}% | |
\par %\vspace{6pt} | |
\parindent \@parindent | |
}% | |
{% | |
\par | |
\hfill | |
\rule[0.5\baselineskip] | |
{\dimexpr(0.5\textwidth-0.5\columnsep-1pt)}{\wttlinewidth} | |
\end{strip} | |
} | |
\else | |
\newenvironment{widetext}[1][2]{}{} | |
\fi | |
} | |
} | |
\endinput |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it intentionally that after the widetext environment the first line of the following text is indented?
This somehow then appears as a new paragraph. According to the code in the example everything should be set in one paragraph.