0

I have create new floats using the below code, it working good.

\newfloat{map}{tbp}{lomap}
\floatname{map}{Map}

\newfloat{photo}{htbp}{lop}
\floatname{photo}{Photo}

I need to rotate these folats(sidewaysphoto), so i have use the below code but only float is rotating but the caption is not showing. please see the below code

\documentclass[twocolumn]{article}
\usepackage[demo]{graphicx}
\usepackage{float}
\usepackage{rotating}
\newcommand{\lipsum}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. In malesuada consequat mollis. Duis viverra vestibulum quam id vehicula. Donec vel tellus a orci adipiscing euismod. Suspendisse lacinia metus lorem. Vivamus pellentesque, lacus quis blandit tincidunt, elit nunc ullamcorper enim, ut laoreet metus risus sed neque. Sed ac nibh ante, pellentesque vehicula sem. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel libero leo. Donec aliquam placerat arcu, et ultrices leo semper et. Curabitur dignissim, eros vitae dignissim porta, velit arcu vehicula tortor, vel blandit sapien magna in risus.}%


\newfloat{map}{tbp}{lomap}
\floatname{map}{Map}
%\DeclareDelayedFloat{map}{Maps}

\newfloat{photo}{htbp}{lop}
\floatname{photo}{Photo}
%\DeclareDelayedFloat{photo}{Photo}
\newfloat{scheme}{htbp}{scheme}
\floatname{scheme}{scheme}


\makeatletter
\def\sidewaysphoto{\@rotfloat{photo}}
\let\endsidewaysphoto\end@rotfloat

\newenvironment{sidewaysphoto*}
               {\@rotdblfloat{photo}}
               {\end@rotdblfloat}

\makeatother

\begin{document}
\lipsum
\begin{sidewaysphoto}
    \centering
    \includegraphics{myPhoto}
    \caption{xxxxxxxMy Photo 1}
\end{sidewaysphoto}

\lipsum
\begin{photo}
    \centering
    \includegraphics{myPhoto}
    \caption{My Photo 2}
\end{photo}
\lipsum
\begin{figure}
    \centering
    \includegraphics{myFigure}
    \caption{My Figure}
\end{figure}
\lipsum
\begin{map}
    \centering
    \includegraphics{myMap}
    \caption{My Map}
\end{map}
\lipsum
\end{document}       
  • Exactly how do you want the photos to rotate? Do you want the caption to rotate as well? Do you want a separate page for every photo (lke sidewaysfigure) or do you something where [htb] makes sense? – John Kormylo May 4 '18 at 14:10
  • @John Kormylo l want to rotate figure like sidewaysfigure without loading caption package is it possible – Shalu May 4 '18 at 21:49
  • From my code i can rotate the figure, using the code \makeatletter \def\sidewaysphoto{\@rotfloat{photo}} \let\endsidewaysphoto\end@rotfloat \newenvironment{sidewaysphoto*} {\@rotdblfloat{photo}} {\end@rotdblfloat} \makeatother from rotate.sty but what happened to caption, if you know please explain, why it's happened – Shalu May 4 '18 at 21:52
1

It seems that the float package replaces \caption with its own version.

This restores the default \caption and uses the "one figure per column" sidewaysfigure approach.

\documentclass[twocolumn]{article}
\usepackage[demo]{graphicx}

\let\normalcaption=\caption
\usepackage{float}
\let\caption=\normalcaption

\usepackage{environ}
%\usepackage{rotating}
\newcommand{\lipsum}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. In malesuada consequat mollis. Duis viverra vestibulum quam id vehicula. Donec vel tellus a orci adipiscing euismod. Suspendisse lacinia metus lorem. Vivamus pellentesque, lacus quis blandit tincidunt, elit nunc ullamcorper enim, ut laoreet metus risus sed neque. Sed ac nibh ante, pellentesque vehicula sem. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel libero leo. Donec aliquam placerat arcu, et ultrices leo semper et. Curabitur dignissim, eros vitae dignissim porta, velit arcu vehicula tortor, vel blandit sapien magna in risus.}%


\newfloat{map}{tbp}{lomap}
\floatname{map}{Map}
%\DeclareDelayedFloat{map}{Maps}

\newfloat{photo}{htbp}{lop}
\floatname{photo}{Photo}
%\DeclareDelayedFloat{photo}{Photo}
\newfloat{scheme}{htbp}{scheme}
\floatname{scheme}{scheme}

\newcommand{\nullcaption}[2][]{}% eat caption and arguments

\NewEnviron{sidewaysphoto}[1][htbp]%
{\sbox0{\let\caption=\nullcaption \BODY}% measure image sans caption
  \begin{photo}[#1]
  \rotatebox{90}{\begin{minipage}[c][\columnwidth][c]{\wd0}
  \BODY
  \end{minipage}}%
  \end{photo}}%

\NewEnviron{sidewaysphoto*}[1][tp]%
{\sbox0{\let\caption=\nullcaption \BODY}% measure image sans caption
  \begin{photo*}[#1]
  \rotatebox{90}{\begin{minipage}[c][\textwidth][c]{\wd0}
  \BODY
  \end{minipage}}%
  \end{photo*}}%
\makeatother

\begin{document}
\lipsum
\begin{sidewaysphoto}
    \centering
    \includegraphics{myPhoto}
    \caption{xxxxxxxMy Photo 1}
\end{sidewaysphoto}

\lipsum
\begin{photo}
    \centering
    \includegraphics{myPhoto}
    \caption{My Photo 2}
\end{photo}
\lipsum
\begin{figure}
    \centering
    \includegraphics{myFigure}
    \caption{My Figure}
\end{figure}
\lipsum
\begin{map}
    \centering
    \includegraphics{myMap}
    \caption{My Map}
\end{map}
\lipsum
\end{document}   

This allows more than one sideways float per column.

\documentclass[twocolumn]{article}
\usepackage[demo]{graphicx}

\let\normalcaption=\caption
\usepackage{float}
\let\caption=\normalcaption

\usepackage{environ}
%\usepackage{rotating}
\newcommand{\lipsum}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. In malesuada consequat mollis. Duis viverra vestibulum quam id vehicula. Donec vel tellus a orci adipiscing euismod. Suspendisse lacinia metus lorem. Vivamus pellentesque, lacus quis blandit tincidunt, elit nunc ullamcorper enim, ut laoreet metus risus sed neque. Sed ac nibh ante, pellentesque vehicula sem. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel libero leo. Donec aliquam placerat arcu, et ultrices leo semper et. Curabitur dignissim, eros vitae dignissim porta, velit arcu vehicula tortor, vel blandit sapien magna in risus.}%


\newfloat{map}{tbp}{lomap}
\floatname{map}{Map}
%\DeclareDelayedFloat{map}{Maps}

\newfloat{photo}{htbp}{lop}
\floatname{photo}{Photo}
%\DeclareDelayedFloat{photo}{Photo}
\newfloat{scheme}{htbp}{scheme}
\floatname{scheme}{scheme}

\newcommand{\nullcaption}[2][]{\par}% eat caption and arguments

\NewEnviron{sidewaysphoto}[1][htbp]%
{\sbox0{\let\caption=\nullcaption \BODY}% measure image sans caption
  \begin{photo}[#1]
  \rotatebox{90}{\begin{minipage}[c][\columnwidth][c]{\wd0}
  \BODY
  \end{minipage}}%
  \end{photo}}%

\NewEnviron{sidewaysphoto*}[1][tp]%
{\sbox0{\let\caption=\nullcaption \BODY}% measure image sans caption
  \begin{photo*}[#1]
  \rotatebox{90}{\begin{minipage}[c][\textwidth][c]{\wd0}
  \BODY
  \end{minipage}}%
  \end{photo*}}%
\makeatother

\begin{document}
\lipsum
\begin{sidewaysphoto}
    \centering
    \includegraphics{myPhoto}
    \caption{xxxxxxxMy Photo 1}
\end{sidewaysphoto}

\lipsum
\begin{photo}
    \centering
    \includegraphics{myPhoto}
    \caption{My Photo 2}
\end{photo}
\lipsum
\begin{figure}
    \centering
    \includegraphics{myFigure}
    \caption{My Figure}
\end{figure}
\lipsum
\begin{map}
    \centering
    \includegraphics{myMap}
    \caption{My Map}
\end{map}
\lipsum
\end{document} 
| improve this answer | |
  • endfloat is not working – Shalu May 6 '18 at 5:30
  • If you are talking about the endfloat package, that would be a new question (unrelated to this solution). – John Kormylo May 6 '18 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.