Texstudio: [enhancement] Put caption above table

Created on 5 Nov 2020  路  7Comments  路  Source: texstudio-org/texstudio

Environment

any

Actual behavior

_Latex > Environments > \begin{table}_ produces this template:

\begin{table}
    % cursor is here
    \caption{}
\end{table}

Enhancement

CMOS, Oxford, and other style guides recommend putting the caption above the table.
I suggest saving a few clicks:

\begin{table}
    \caption{} % put the caption right after begin...
    % ... and put the cursor here
\end{table}

Most helpful comment

@homocomputeris caption package _cannot_ do this. From the doc of caption, option position,

Please note that position=top does _NOT_ mean that the caption is actually placed at the top of the figure or table. Instead the caption is usually placed where you place the \caption command.

But you can config what is input by menu item _Latex > Environments > \begin{table}_ in Configure TeXstudio ("Show Advanced Options" checked) > Menus > &LaTeX > &Environments: changing \begin{table}%\%|%\\caption{}%\\end{table} to \begin{table}%\caption{}%\%|%\\end{table} does the work.
image

All 7 comments

You could rather use the floatrow package and its \floatsetup[table]{capposition=top} setting:

\documentclass{article}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{floatrow}

\floatsetup[table]{capposition=top}

\begin{document}
\lipsum[1]
\begin{table}[ht]
  \centering
  \begin{tabular}{|c|}
    \hline
    Foo\\\hline
    bar\\\hline
  \end{tabular}
  \caption{Foo bar}
\end{table}
\lipsum[2]
\begin{figure}[ht]
  \centering
  \includegraphics[width=.25\linewidth]{example-image-a}
  \caption{Bar foo}
\end{figure}
\lipsum[3]
\end{document}

image

That makes sense. The package is 11yo, though.

I also would not want to change default set-up for every user because of this request.
I would assume that the majority uses the set-up as is and does not complain.
(and the package solution is the superior one as caption position should be part of the document style)

Then would be great to able to customize these environments somehow without creating new macros.

(and the package solution is the superior one as caption position should be part of the document style)

A lot of things should, but many are configured via low-level commands. In Latex3 maybe...

You're right.
Also, the maintained caption package can do this too.

@homocomputeris caption package _cannot_ do this. From the doc of caption, option position,

Please note that position=top does _NOT_ mean that the caption is actually placed at the top of the figure or table. Instead the caption is usually placed where you place the \caption command.

But you can config what is input by menu item _Latex > Environments > \begin{table}_ in Configure TeXstudio ("Show Advanced Options" checked) > Menus > &LaTeX > &Environments: changing \begin{table}%\%|%\\caption{}%\\end{table} to \begin{table}%\caption{}%\%|%\\end{table} does the work.
image

@muzimuzhi Good to know!

BTW, maybe this entry could be something like \begin{table}%\%<tabular%>%\\caption{%<caption%>}%\\end{table} (and similarly for the other ones).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Krzmbrzl picture Krzmbrzl  路  4Comments

01000110 picture 01000110  路  10Comments

juliandragon picture juliandragon  路  6Comments

antmw1361 picture antmw1361  路  7Comments

kendonB picture kendonB  路  10Comments