0

When integrating standard LaTeX output from a database or from software like pandoc, the actual content cannot be changed. To still be able to layout the document, it is important to have redefinitions in the preamble.

I am looking for preamble commands that translate (redefine layout visually) from

\begin{figure}[htbp]
\centering
\includegraphics{test.png}
\caption{test}
\end{figure}

to

\noindent\begin{minipage}[t]{0.5\textwidth}
\begin{figure}[H]
\centering
\includegraphics{test.png}
\end{figure}
\end{minipage}
\hspace{0.03\textwidth}

and quotations from:

\begin{quote}
test
\end{quote}

to

\noindent\begin{minipage}[t]{0.4\textwidth}
test
\end{minipage}

My current approach is a simple perl script that does these translations. But I want to omit in-between-operations for the sake of simplicity. Especially renewing the figure environment has been a big threat to me, because here I mostly do not want to renew anything (apart from removing the caption), but just enveloping a minipage around the existent figure. What are the standard approaches in the world of tex monks wisdom?

6
  • why put a figure in a minipage? That can not do anything useful. Mar 2, 2016 at 14:54
  • The presented minipage figure followed by the presented minpage text results in a nice two-column arrangement of figure (left) and text (right).
    – Martin
    Mar 2, 2016 at 14:59
  • No that's just two minipages, why have a figure environment inside the minipage, normally that is an error, if it doesn't give an error with H that's an oversight. Mar 2, 2016 at 15:11
  • @DavidCarlisle Hm, I am confused, why does it then work here: tex.stackexchange.com/a/296954/32082 ? What else do you recommend to achieve figure and text side by side like in this example?
    – Martin
    Mar 2, 2016 at 15:22
  • it probably works it is just doing nothing, try same without the figure env, or equivalently try the answer I posted Mar 2, 2016 at 15:47

1 Answer 1

1
\renewenvironment{figure}[1][]
  {\noindent\begin{minipage}[t]{0.5\textwidth}\renewcommand\caption[1][]{}}
  {\end{minipage} \hspace{0.03\textwidth}}

\renewenvironment{quote}
  {\noindent\begin{minipage}[t]{0.4\textwidth}}
  {\end{minipage}}

will do what you ask although both redefinitions seem very strange, with the new definitions, if there is not a blank line before the environment they will be set inline, and in the figure case there is one word space and one space of width .03\textwidth after the figure? I did not put the figure[H] inside the minipage as that would not do anything useful, essentially H just redefines figure to be a non-floating minipage anyway.

2
  • This solution is promising, but both minipages are neither side-by-side nor vertically aligned at top, when a figure environment is followed by a quote environment.
    – Martin
    Mar 2, 2016 at 15:54
  • Your solution works if you leave out [t] for both commands. However, the two columns (minipages) are not vertially top-aligned anymore. Furthermore, the whole idea only works if there is not blank line between figure and quote, but this is already a problem intrinsic to the question...
    – Martin
    Mar 2, 2016 at 16:35

You must log in to answer this question.

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