Tufte-LaTeX / tufte-latex

A Tufte-inspired LaTeX class for producing handouts, papers, and books
https://tufte-latex.github.io/tufte-latex/
1.69k stars 301 forks source link

Fullwidth caption #145

Open HenningTimm opened 5 years ago

HenningTimm commented 5 years ago

This PR adds the figurefw and tablefw environments which have a full width caption for use with full page and other large floats (as mentioned in #134). Both behave exactly like the figure* and table* environments, but also span the caption across the full width of the page.

I added an example to the sample-book file, which recycles the sine wave figure. I am not sure, if an example is necessary and if the table example could be enough. Personally, I required this mostly for full-page figures that also needed long explanatory texts, so I added that to the document.

I only tested this with the sample book yet, so I would appreciate anyone testing that this doen't break in larger projects.

HenningTimm commented 5 years ago

A small issue I already identified is that the bounding box of the caption is not computed correctly yet. When placed in text, the caption is written into the following text. Additionally, when working with subfloat, subcaptions beneath the subfloats are also written over.

HenningTimm commented 5 years ago

@Tafnab identified a potential problem with subtables and their captions, that I unfortunately have no time to investigate at the moment. For details, please refer to Issue #134.

BeastyBlacksmith commented 4 years ago

Do the references get correctly labeled with cref?

HenningTimm commented 4 years ago

I don't know from the top of my head. I never (knowingly) used cref before. However, if I remember correctly, I only adapted sizes and margins. If labels work correctly with "normal" image environments, I'd wager they still do with the fullwidth ones.

jklymak commented 4 years ago

I don't know enough tex to vouch for the quality of this PR, but something like this would be very helpful to me...

DNF2 commented 3 years ago

I very much need this functionality.

But looking at the list of PRs going back several years, with apparently no activity, is it fair to say that this repository has been abandoned?

HenningTimm commented 3 years ago

I have not seen any activity here in the last years. I wouldn't hold my breath.

If you want to take the (a little rocky) road and use this feature without it being merged into the main branch: This works and you only need to download two files. The majority of the files in this repo are for the example projects to compile but are not needed for the actual document classes. To work with this locally you will need to do following:

  1. Find a patched version of the file tufte-common.def. You can use the one from this branch or from my fork, but probably the most up-to-date version is the one from @visika's fork (who applied two additional PRs as well). Place this file in your working directory next to your latex file.
  2. Download the specific class you would like to use (tufte-book.cls or tufte-book.cls) from the either from the same source (or use the "normal" one) and place it in the same folder.
  3. Use the respective document class in your preamble, e.g. for tufte-book:
    \documentclass[a4paper,nobib]{tufte-book}
  4. You should now be able to use the figurefw environment:

    \begin{figurefw}[p]
        \centering
        % your image content here
        \includegraphics[width=.75\textwidth]{figures/your_figure_path}
    
        \caption{Caption text}
        \label{fig:my_fullwidth_figure}
    \end{figurefw}

I am reasonably sure this will work, but to make sure I will test this later this week. I verified that this works.

Tafnab commented 3 years ago

I very much need this functionality.

But looking at the list of PRs going back several years, with apparently no activity, is it fair to say that this repository has been abandoned?

I have a number of FW environments using a modified tufte style. Can you be more specific about what you want, maybe some pseudo-code?

DNF2 commented 3 years ago

Can you be more specific about what you want

I looking for full width versions of table and figure, with captions not positioned as sidenotes. Preferably, it should be possible to put the caption below or above the float.

Pseudocode:

\begin{table*}
    \centering
    \caption{Here's my caption text. \label{tab:example}}
    \begin{tabular}
    ....
    \end{tabular}
\end{table*}

This would make a full-width table with the caption positioned above the table, and with the caption using the full table width (if the text is long enough.)

Tafnab commented 3 years ago

Here is some working code from a book I did. I substituted "etc" for the actual words.

I can't attach the style and cls files because their "type" isn't supported by this "forum". A major oversight for LaTeX forum, I'd say.

I think they are the same ones provided by the original author. I can't remember whether I did any fixes. If this code doesn't work for you, find a way for me to ship the files to you.

Header: (missing a huge amount of stuff, but these linesare the essentials)

\documentclass[a4paper,twoside]{tufte-book} % Use the tufte-book class which in turn uses the tufte-common class
\PassOptionsToPackage{table,dvips,dvipsnames,svgnames,rgb,hyperref}{xcolor}
%\usepackage{pslatex}
\usepackage{tufte-foot} % This is a local style file placed in the build directory. I found it on the internet. 

***snip***
\DeclareCaptionFormat{thikcap}{\pdfrender{TextRenderingMode=2,LineWidth=0.18pt}#1#2#3\par} % custom format of caption to make the characters thicker.

Full width table, caption below:

\begin{tablefw}
    \begin{tabular}{p{3.7cm}p{3.7cm}p{8.0cm}}\arrayrulecolor{white}
        \toprule
        {Name} & {Example} & {Explanation} \\
        \midrule
        {etc} & {etc.} & etc \\

        \bottomrule
    \end{tabular}
    \caption{Caption Here}
\end{tablefw}
\vspace{5ex}

The following produces a full width figure on full page: (I may have been having problems with this figurefw; can't remember. This page used a jpg graphic embedded directly, with caption above figure):

 \begin{figurefw}[t]
           \caption[t]{{\bf Circuit Diagram} plus really long text.}
                \label{fig:big_circuit_problem}
\end{figurefw}

            \begin{fullwidth}
                %\vphantom{A}
                \begin{minipage}[]{\textwidth}
                    \vspace{2.5cm}
                    \includegraphics[width=1.5\textwidth]{figures/big_problem_circuit.jpg}\label{test}
                \end{minipage}
            \end{fullwidth}
            \clearpage
            \newpage
DNF2 commented 3 years ago

Thank you very much, @Tafnab.