2

I am trying to add a TOC entry with text and a figure to an ACS paper draft. I would like to have everything fit in a box of width=3.25in and height=1.75in, with the figure on the right and the text on the left, everything being centered vertically. How can I achieve this?

This is my current minimum working example illustrating the problem:

\documentclass[journal=apchd5,manuscript=letter]{achemso}
\title{Title}

\begin{document}

% required max size
\includegraphics[width=3.25in, height=1.75in]{example-image-a}

% what I think mimics the ACS tocentry environment
\begin{center}
  \fbox{
    \begin{minipage}{3.25in}
      \vbox to 1.75in{
        \parbox[c]{0.5\textwidth}{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Arcu non odio euismod lacinia at quis risus sed vulputate.}\includegraphics[width=0.5\textwidth]{example-image-a}
      }
    \end{minipage}
  }
\end{center}

% ACS tocentry environment
\begin{tocentry}
  \parbox[c]{0.5\textwidth}{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Arcu non odio euismod lacinia at quis risus sed vulputate.}\includegraphics[width=0.5\textwidth]{example-image-a}
\end{tocentry}

\end{document}

I cannot get the text and figure centered vertically. In addition, the frame ends up being heigher than height=1.75in.

How can I center a text and figure vertically in a framed box of fixed size? How can I do it within the tocentry environment from the achemso package?

1 Answer 1

3

Here is an alternate version called alttocentry that will keep the box size correct, unless the text becomes too much for the space. In the first instance, I show \rules to the right and below to confirm the dimensions.

Adjustable parameters include \fboxsep, \fboxrule, \mygap, \imgwd, \boxwd, and \boxht.

\documentclass[journal=apchd5,manuscript=letter]{achemso}
\usepackage{stackengine}
\newlength\mygap
\setlength\mygap{5pt}
\newlength\boxwd
\setlength\boxwd{3.25in}
\newlength\boxht
\setlength\boxht{1.75in}
\newlength\imgwd
\setlength\imgwd{.5\boxwd}
\newcommand\mytextwd{\boxwd-\imgwd-\fboxsep-\fboxrule-\mygap}
\newcommand\mytextenv{\setstretch{1.1}\sffamily}
\newcommand\myboxshift{-.5\dimexpr\height-.5\ht\strutbox+.5\dp\strutbox\relax}
\newcommand\myboxopts{width=\imgwd-\fboxsep-\fboxrule}
\newcommand\myaddgap{.5\boxht-.5\ht0-.5\dp0-\fboxsep-\fboxrule}
\newenvironment{alttocentry}[1]{
  \def\myimgname{#1}%
  \setbox0=\hbox\bgroup\begin{minipage}{\mytextwd}\mytextenv\strut\ignorespaces
}{%
  \end{minipage}%
  \kern\mygap%
  \raisebox{\myboxshift}%
  {\expandafter\includegraphics\expandafter[\myboxopts]{\myimgname}}%
  \egroup%
  \centerline{\fbox{\addstackgap[\myaddgap]{\copy0}}%
  \showboxht%%%%% CAN GET RID OF THIS
  }%
}
%%%%% CAN GET RID OF THESE, ONCE HAPPY WITH RESULT
\newcommand\showboxht{%
  \rlap{\,\rule[-.5\boxht+.35\ht\strutbox-.35\dp\strutbox]{3pt}{\boxht}}}
\newcommand\showboxwd{\par\centerline{\rule{3.25in}{3pt}}}
%%%%%%%%%
\title{Title}
\begin{document}
\begin{alttocentry}{example-image-a}
  Lorem ipsum dolor sit amet, 
  consectetur adipiscing elit, 
  sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.%
\end{alttocentry}
\showboxwd%%%%% CAN GET RID OF THIS
\bigskip

\let\showboxht\relax
\setlength\imgwd{.45\boxwd}

\begin{alttocentry}{example-image-b}
This is a test of an toc entry smaller than the figure.
\textbackslash imgwd reduced.
\end{alttocentry}
\begin{alttocentry}{example-image-b}
This is a test of an toc entry larger than allowed vertical space.
This is a test of an toc entry larger than allowed vertical space.
This is a test of an toc entry larger than allowed vertical space.
This is a test of an toc entry larger than allowed vertical space.
\end{alttocentry}
\end{document}

enter image description here

I'm not sure that the actual tocentry environment preserves the vertical dimension. But here is my attempt using the actual environment.

\documentclass[journal=apchd5,manuscript=letter]{achemso}
\title{Title}
\begin{document}
% ACS tocentry environment
\begin{tocentry}
\vfill
  \begin{minipage}{0.5\textwidth}Lorem ipsum dolor sit amet, consectetur adipiscing elit, 
  sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \end{minipage}%
  \raisebox{-.5\dimexpr\height-\ht\strutbox+\dp\strutbox\relax}%
  {\includegraphics[width=0.5\textwidth]{example-image-a}}
\\\vfill
\end{tocentry}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .