Tag Info

Hot answers tagged

10

Yes, see the documentation of the buildpage_filter callback, and possibly also the pre_output_filter callback. Note however that unlike the linebreaking algorithm, there are very few parts of the page breaker that you are forced to use directly, which is why different strategies can be programmed even in classic tex without needing lua extensions, such as ...


4

latex headings include code to prevent a page break until a couple of lines after a heading, so it best to define this as an unnumbered heading: \documentclass[a5paper]{book} \usepackage{geometry} \usepackage{lipsum} \makeatletter \newcommand{\character}{% \@startsection {section}{1}{\z@}% {-3.5ex \@plus -1ex \@minus ...


3

Not precisely what the O.P. wants to have (not twocolumn mode and automatically), but parallel with parallel package: \documentclass{article} \usepackage{parallel} \usepackage{mathtools} \usepackage{amsthm} \newtheorem{definition}{Definition} \newtheorem{example}{Example} \begin{document} \begin{Parallel}{0.4\textwidth}{0.4\textwidth} \ParallelLText{% ...


3

You can still use a longtable as this: \documentclass[12pt,english,nohyper]{tufte-handout} \usepackage{longtable} \begin{document} \begin{longtable}{cc p{1em} cc} \cline{1-2} \cline{4-5} & vals& & & vals\\ \cline{1-2} \cline{4-5} a & 3.39& & a & 3.39\\ b & 4.35& & b & 4.35\\ c & 6.16& ...


3

Here is a quick demo of linking R and LaTeX using the 'knitr' package. This has been run on Windows 8.1, with MikTeX 2.9, and TeXmaker 4.4.1 as the IDE. The following code is saved as knit02.Rnw (and this is case sensitive). With the package 'knitr' installed in R 3.1.3 you run the command: knit("knit02.Rnw"). This will generate the file 'knit02.tex' ...


2

What about the following idea? It's much different from yours (or perhaps the class author's), but perhaps more robust as it uses the \label-\ref system to determine whether a page break has occurred mid-question: \documentclass{article} \usepackage[paper=a5paper,margin=1in]{geometry}% Just for this example \usepackage{multido}% Just for this example ...


2

The images will only be listed if you give them a caption, if you put them, in table environments the order of the three items will be maintained.


2

It’s a bit sad to see how easily people are inclined to forget the good ol’ ways of doing things… Seriously, this question (like others I have already seen on TeX.SX) looks like a classical problem which is discussed, and solved, on page 111 of The TeXbook, where the \filbreak command is introduced. Quoting from there: The most interesting macro that ...


2

Alternative: Use tcolorbox (Gonzalo Medina was proposing it while I wrote this answer ;-)) with the breakable option. There is a huge number of options for the shape, colours etc -- it's impossible to show them all here in a small example. \documentclass{article} \PassOptionsToPackage{svgnames}{xcolor} \usepackage[most]{tcolorbox} \usepackage{blindtext} ...


2

If I fix the unrelated errors in your example (missing files and unescaped _ in headings) then as expected there are no page breaks between the headings: \documentclass[a4paper,11pt,titlepage]{article} \title{...} \author{...} %%Packages \usepackage[utf8]{inputenc} \usepackage{hyperref} \usepackage{float} \usepackage{caption} %%Commands ...


2

Use the mdframed key to interact with the mdframed package and set the margins to the appropriate values (the settings I used in the code below reproduce the original settings): \documentclass{article} \usepackage[english]{babel} \usepackage[margin=2cm]{geometry}% just for the example \usepackage{xcolor} \usepackage{amsthm} \usepackage{thmtools} ...


2

Here is a simple solution with the framed option of ntheorem, which has tools for selectively typeset theorem lists: \documentclass{article} \usepackage[english]{babel} \usepackage[margin=2cm]{geometry}% just for the example \usepackage[x11names]{xcolor} \usepackage{lipsum} \usepackage{amsmath} \usepackage[thmmarks, thref, amsmath, framed]{ntheorem} ...


2

Wrong syntax, please check the documentation of package fancyvrb. The environment name starts with an uppercase letter V and the options are not inbetween, but follow \begin{Verbatim}. \begin{Verbatim}[samepage=true, gobble=4] sc <- read.table("~/pathToData/sc.data.txt", quote="\"", comment.char="") some more code and even more ...


2

This uses the titlesec package to build on David's suggestion and converts the use of \newenvironment to \newcommand since you want a command rather than an environment judging by the syntax you wish to use. \documentclass[12pt]{report} \usepackage{titlesec} \titleformat{\section}[block]{\centering\bfseries\sffamily\large}{\thesection}{0pt}{}{} ...


2

Just as with your specification for \section, you can move all the printing commands into the final argument. This then allows you to color them with \textcolor. In your example you then get on page two, rather a page break between the section commands. \documentclass{article} \usepackage{fontspec} \usepackage[explicit]{titlesec} \usepackage{xcolor} ...


1

The best way to cope with formatting of section titles is to use a macro with one argument in the last argument to \titleformat. Color specifications should only go in this auxiliary macro. Here is an example. \documentclass{article} \usepackage{fontspec} \usepackage{titlesec} \usepackage{xcolor} \usepackage{lipsum} % Title/Heading Formatting % SECTION ...


1

You can use the \needspace macro (directly available in memoir, for other classes there's the needspace package). \documentclass[b5paper]{memoir} \usepackage{lipsum} \renewcommand{\clearforchapter}{} \pagestyle{plain} \chapterstyle{default} \renewcommand*{\chapterheadstart}{% \par \needspace{10\onelineskip} \vspace{\beforechapskip} ...


1

Try \\* to suppress a page break after a forced line break.


1

You can add a new key to quoting. Specifying this key should allow page breaks only at explicit paragraphs (blank lines). \documentclass[a4paper]{memoir} \usepackage[indentfirst=false]{quoting} \usepackage{lipsum} \makeatletter \define@key{quo}{nopagebreak}[true]{\interlinepenalty=10000 } \makeatother \raggedbottom \begin{document} \lipsum[1-4] ...


1

\documentclass[paper=A6]{scrartcl} \usepackage{needspace} \usepackage{blindtext} \newsavebox\TBox \newcommand\newpageoptional[1]{% \savebox\TBox{\parbox{\linewidth}{#1}}% to get the height of the text \needspace{\dimexpr\ht\TBox+\dp\TBox}% totalheight #1} \begin{document} \blindtext \newpageoptional{% Text and code 2 with blindtext ...


1

Probably you want \raggedbottom which means that when there's no space for something in a page a new one is open without flushing the contents to align to the bottom. Plus a {minipage} environment (which doesn't break across pages). Just put \raggedbottom in the preamble and use \newcommand\newpageoptional[1] ...


1

If you use \begin{table}[p] then the tables are restricted to float pages and no text will be under them. Note however that by default latex will not put text under a float unless at least 20% of the page has text. This is the parameter \textfraction which by default (and in article class) is set at 0.2.


1

I think I have come pretty close to a real solution. It's not particularly minimal, but it does most of what I hoped to accomplish. Basically this works by redefining line breaks in the source code to hook a counter that increments line by line except inside instructornotes. For the initial student compile, we hook into every shipout to record the line ...


1

My original idea was to change the footer at the environment start and revert it at the end, but this fails if the environment ends whilst TeX is storing material that will ultimately contain a page break (most likely if the environment end ends up near the top of a page). I think the right way to do this is to put a switch in the footer itself, to detect ...


1

Add \vfil before the center environment in your command: \documentclass[a5paper]{book} \usepackage{geometry} \usepackage{lipsum} \newcommand{\character}[1]{% \vfil \begin{center} \textsc{#1} \end{center} } \begin{document} \character{Alice} \lipsum[2] \character{Bob} \lipsum[2] \character{Charles} \lipsum[2] \character{David} \lipsum[2] ...



Only top voted, non community-wiki answers of a minimum length are eligible